NuttX on a BluePill

Anything not related to STM32
acassis
Posts: 22
Joined: Mon Sep 18, 2017 3:27 pm

Re: NuttX on a BluePill

Post by acassis » Wed Sep 20, 2017 11:32 pm

Pito wrote:
Wed Sep 20, 2017 3:09 pm
This is the way I created a shell script "mrdisk" for creating a ramdisk :) without an editor available..
Copy and paste work perfectly in TeraTerm, set NewLine to CR/CR. I've also set 256chars per line via menuconfig.
Fantastic stuff the ">" and ">>" work here!

Code: Select all

nsh> echo "mkrd -m 1 -s 512 800" >> /sdcard/mrdisk
nsh> echo "mkfatfs /dev/ram1" >> /sdcard/mrdisk
nsh> echo "mount -t vfat /dev/ram1 /ramdisk" >> /sdcard/mrdisk
nsh> cat /sdcard/mrdisk
mkrd -m 1 -s 512 800
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /ramdisk
nsh>
nsh> sh /sdcard/mrdisk
nsh>
nsh> df
  Block  Number
  Size   Blocks     Used Available Mounted on
   512      761        2       759 /ramdisk
 32768   485936     3179    482757 /sdcard
nsh>
What is nice you can copy and paste the entire block - like

Code: Select all

mount -t vfat /dev/mmcsd0 /sdcard
mkrd -m 1 -s 512 800
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /ramdisk
df

into the terminal (115k2 here), with Linux or Win line endings, and with 0 (zero !!!) char and line transmit delays, and you get

Code: Select all

NuttShell (NSH)
No MOTD string provided
nsh> mount -t vfat /dev/mmcsd0 /sdcard
nsh> mkrd -m 1 -s 512 800
nsh> mkfatfs /dev/ram1
nsh> mount -t vfat /dev/ram1 /ramdisk
nsh> df
  Block  Number
  Size   Blocks     Used Available Mounted on
   512      761        2       759 /ramdisk
 32768   485936     3178    482758 /sdcard
nsh>
:shock: Great!!
The best way to have initialization scripts is creating a ROMFS that will be mounted at /etc with the file /etc/init.d/rcS that will be executed after the system boot. See here: http://nuttx.org/Documentation/NuttShel ... rtupscript

User avatar
Squonk42
Posts: 128
Joined: Thu Dec 29, 2016 9:25 am
Location: Bordeaux, France

Re: NuttX on a BluePill

Post by Squonk42 » Fri Sep 22, 2017 6:29 am

@acassis: thank you for your video tutorials, they are great!

I had a small problem while flashing a Bluepill fresh out of its anti-static bag: I got this error message from openocd:

Code: Select all

Error: stm32x device protected
I solved this issue by sending:

Code: Select all

openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "stm32f1x unlock 0" -c "reset halt"
I try to use the Bluepill as an I2C slave device, like an I2C extension to an RPi (or any other xPi). I am not able to have it working ith Arduino, and I wonder if this could work with NuttX? I would implement a simple I2C command switch to perform GPIO read/write, PWM, etc.

acassis
Posts: 22
Joined: Mon Sep 18, 2017 3:27 pm

Re: NuttX on a BluePill

Post by acassis » Fri Sep 22, 2017 11:39 am

Squonk42 wrote:
Fri Sep 22, 2017 6:29 am
@acassis: thank you for your video tutorials, they are great!

I had a small problem while flashing a Bluepill fresh out of its anti-static bag: I got this error message from openocd:

Code: Select all

Error: stm32x device protected
I solved this issue by sending:

Code: Select all

openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "stm32f1x unlock 0" -c "reset halt"
I try to use the Bluepill as an I2C slave device, like an I2C extension to an RPi (or any other xPi). I am not able to have it working ith Arduino, and I wonder if this could work with NuttX? I would implement a simple I2C command switch to perform GPIO read/write, PWM, etc.
Hi Squonk42,

NuttX has the callbacks to support I2C Slave: include/nuttx/i2c/i2c_slave.h, but AFAIK nobody implemented the I2C Slave driver yet.

You will need to take a look at www.st.com/resource/en/application_note/cd00209826.pdf to understand how it works and how to implement it. It should be a good contribution case you decide to carry on with this idea.

User avatar
Pito
Posts: 1600
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: NuttX on a BluePill

Post by Pito » Fri Oct 20, 2017 8:08 am

@Alan: does the NuttX support hotswapping of the Sdcard when the Card Detect signal is available on the socket?
Like mount/umount -> hotswap -> mount..
Here without Card Detect signal (I do not have the signal on my socket available).

Code: Select all

nsh> mount -t vfat /dev/mmcsd0 /sdcard
nsh> ls -l /sdcard
/sdcard:
 -rw-rw-rw-  480054 Mandel.bmp
 -rw-rw-rw- 8388608 STM32Demo.bin
..
nsh> umount /sdcard
nsh> ls -l /sdcard
nsh: ls: stat failed: 2
nsh> mount -t vfat /dev/mmcsd0 /sdcard
nsh> ls -l /sdcard
/sdcard:
 -rw-rw-rw-  480054 Mandel.bmp
 -rw-rw-rw- 8388608 STM32Demo.bin
 -rw-rw-rw- 8388608 XXXX.bin
..
nsh> umount /sdcard
nsh> ls -l /sdcard
nsh: ls: stat failed: 2                 
nsh>                                   <<<<<<<<<<<<< SDCARD HOTSWAPPED
nsh> mount -t vfat /dev/mmcsd0 /sdcard
nsh: mount: mount failed: 19
nsh> ls -l /dev
/dev:
 crw-rw-rw-       0 console
 brw-rw-rw-       0 mmcsd0
 crw-rw-rw-       0 null
 crw-rw-rw-       0 ttyS0
 crw-rw-rw-       0 urandom
 crw-rw-rw-       0 zero
nsh>
Also, can we mount several sdcards?
Pukao Hats Cleaning Services Ltd.

Post Reply