NuttX on a BluePill

RogerClark
Thu Sep 07, 2017 1:19 am
I came across this while looking for something else …

https://acassis.wordpress.com/2016/06/1 … -00-board/

https://en.wikipedia.org/wiki/NuttX


Squonk42
Thu Sep 07, 2017 5:24 am
I wonder how usable is this port? I mean, what part of Nuttx is available (network, fs,threads…) and how much is left for applications?

zoomx
Thu Sep 07, 2017 6:35 am
Interesting!

RogerClark
Thu Sep 07, 2017 6:55 am
Yep.

Seems lot to squeeze into a Blue Pill, they also seem to support the F4

http://www.nuttx.org/doku.php?id=wiki:g … overy_unix


zoomx
Thu Sep 07, 2017 1:25 pm
Maybe not!
https://github.com/robbie-cao/nuttx/tre … 03-minimum

rreignier
Tue Sep 12, 2017 9:51 pm
Some weeks ago, I have also came across those Youtube Videos: https://www.youtube.com/channel/UC0QciI … luw/videos

Pito
Wed Sep 13, 2017 12:10 pm
Cool! The posix stuff reminds me on my retrobsd experiments..
Worth of trying on my Blue103ZE and Black407ZE with installed 512KB of ram :)
The 407 may support MPU.
Btw, the BP blinking led demo (from youtube) created binary of 41kB (incl shell).

RogerClark
Wed Sep 13, 2017 10:05 pm
41k is not too bad considering the size of the OS…

Pito
Thu Sep 14, 2017 4:47 pm
Ok, I could not resist – :)
-rwxrwxr-x 1 pito pito 40948 Sep 14 18:46 nuttx.bin

acassis
Mon Sep 18, 2017 3:39 pm
Hey guys,

I’m the author of the blog post and creator of the video tutorials.

Nice to know you are enjoying it!!!

In fact the BluePill board (called stm32f103-minimum on NuttX) is not the best board to test all NuttX features. It could be compared to Arduino Uno: a nice introducing board, but if you want to test more advanced features it is better to use Arduino Mega or other board.

But I decided to use this board because it is really inexpensive (less than US$ 2.00).

I will try to produce many video tutorials with this board as possible before moving to some more advance board: maybe STM32F4DISCOVERY or NUCLEO-L476RG board, I didn’t decide yet.


acassis
Mon Sep 18, 2017 3:45 pm
Hi Pito,

You can use an external 4MB SPI Flash.

I bought it from Tindie, but it is sold out now:

https://www.tindie.com/products/nifteec … q32fvzpig/

You can find this flash at Aliexpress and eBay.

The video tutorial explaining how to configure it is here:

https://www.youtube.com/watch?v=KS9nAwWKdCc


Pito
Mon Sep 18, 2017 4:11 pm
@acassis: Hi, nice stuff and videos!
Let me ask you following – I have got STM32F103ZET and STM32F407ZET both with 512kB (EDIT:) EXTERNAL SRAM installed (available for program/data from 0x68000000 upwards). SRAM works fine.
Now, how can I utilize that “huge SRAM” space with NuttX ???????
P.

acassis
Mon Sep 18, 2017 4:32 pm
Hi Pito,

Inside NuttX source code you need to have a configuration for your board.

For example, for your STM32F103ZET board (does it has an official board name?) you can copy the stm32f103-minimum:

cp -a configs/stm32f103-minimum configs/stm32f103zet-boardname

Then you need to edit the configs/Kconfig to include your new board (three places in this file).

Also change the configs/stm32f103-minimum/src/stm32f103_minimum.h to stm32f103zetboardname/src/stm32f103zet_boardname and replace the STM32F103C8 with STM32F103ZE in the defconfig.

To increase the memory you need to edit the linker script configs/stm32f103zet_boardname/scripts/ld.script this way:

MEMORY
{
flash (rx) : ORIGIN = 0x08000000, LENGTH = 512K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}

It is not hard, you just need to keep the consistence. There are other files that you will need to change inside the configs/stm32f103zet_boardname/src but you will figure-out it easily.


Pito
Mon Sep 18, 2017 4:45 pm
For example, for your STM32F103ZET board (does it has an official board name?) you can copy the stm32f103-minimum:
cp -a configs/stm32f103-minimum configs/stm32f103zet-boardname

The boards will be named ie:
stm32f103ze-sram
stm32f407ze-sram

It is important to be able to run the code off the external SRAM, not only to use the SRAM for Heap.
I tested several variants of the external SRAM usage and all worked fine.
viewtopic.php?f=28&t=1651&start=140#p22472


acassis
Mon Sep 18, 2017 5:25 pm
Hi Pito,

Sorry, only now I understood you have an external SRAM chip connected to the FSMC interface

Please use this source code as reference:

stm3240g-eval/src/stm32_selectsram.c
stm3240g-eval/src/stm32_deselectsram.c

Also you need to enable “External SRAM on FSMC” in the menuconfig at System Type

I never used the FSMC, so I couldn’t help too much. I suggest you to ask for help at NuttX mailing list (in the Yahoo group) case you face some issues.


Pito
Mon Sep 18, 2017 6:14 pm
To enable/disable fsmc sram interface is something we did in past here.
What I do not know (never touched NuttX before) is following (newbie Qs):
What NuttX can do with an external SRAM attached? How it is used? Can I load and execute binaries off the external sram (like in unix)? For example I load 200kB text (with 200kB of data) into the external sram and run it?
PS: From my first search on yahoo NuttX group (“external sram”) it seems people use the external sram as a heap only..

acassis
Mon Sep 18, 2017 6:26 pm
Hi Pito,

The external SRAM can be used as normal RAM of NuttX (like the internal SRAM).

You can run ELF files. You can support a frame buffer. You can add the external SRAM to the heap where it can be used just like on-chip SRAM.

It is all combined in the memory manager with mm_addregion. You have to set CONFIG_MM_REGIONS=2, define CONFIG_HEAP2_START, and CONFIG_HEAP2_SIZE. Then it is just like having a huge on-chip SRAM.

https://bitbucket.org/nuttx/nuttx/src/3 … eheap.c-77

NuttX support loading ELF binary, loading kernel module (like Linux kernel), loading dynamic library. There are examples of loading modules at apps/example/elf and /module and /sotest .

There is a group/mailing list: https://groups.yahoo.com/neo/groups/nuttx/info (I configured Yahoo group to send me email like an ordinary mailing list).

I prefer mailing list or even better some blog posts, because forum we spend much time reading the people discussing and many times if goes off-time. A blog/wiki page is more direct to the point ;-)


Pito
Mon Sep 18, 2017 6:34 pm
Alan thanks!
That is something I was looking for.. Not asking details here, just Qs on feasibility..

RogerClark
Mon Sep 18, 2017 10:17 pm
[acassis – Mon Sep 18, 2017 3:39 pm] –
Hey guys,

I’m the author of the blog post and creator of the video tutorials.

Nice to know you are enjoying it!!!

In fact the BluePill board (called stm32f103-minimum on NuttX) is not the best board to test all NuttX features. It could be compared to Arduino Uno: a nice introducing board, but if you want to test more advanced features it is better to use Arduino Mega or other board.

But I decided to use this board because it is really inexpensive (less than US$ 2.00).

I will try to produce many video tutorials with this board as possible before moving to some more advance board: maybe STM32F4DISCOVERY or NUCLEO-L476RG board, I didn’t decide yet.

Thanks for posting..

I think the cool thing about running NuttX on the BluePill is the low cost of the board, and yet to still run something akin to a fully fledged OS.

We already have FreeRTOS running on the BluePill, but its a different class of OS to what NuttX provides.

Using bigger boards is great, but the cost if the boards is often more than a PRi Zero, (or a C.H.I.P board) in which case the Zero etc is often the better option.


acassis
Mon Sep 18, 2017 10:31 pm
Hi Roger,

Completely agree! This is because I decided to port NuttX for RPi:

https://bitbucket.org/acassis/nuttx_bcm2835

I just started the board port. Porting NuttX for a high-end CPU is more complex than porting it to a low-end microcontroller, because the MMU (virtual memory things). I think porting NuttX for RPi will let more people to discover about this nice RTOS.

I also used FreeRTOS in the past, but today I think NuttX is a better option, you don’t need to learn a different API to create your applications and you get everything integrated in the system. Although for really low-end MCUs (less than 8KB RAM and 16KB Flash) I think FreeRTOS, Chibios or Contiki could be a better option.

Please see more about NuttX advantages in this article I published at Embedded.com:
http://www.embedded.com/electronics-blo … -you-care-


RogerClark
Mon Sep 18, 2017 10:38 pm
@acassis

Are you porting to the full RPi or the Zero ? (or is it the same ?)


Pito
Mon Sep 18, 2017 10:40 pm
I think RPi and our MCUs are 2 different worlds with different use cases. I messed a lot with retrobsd.org which is almost full implementation of bsd2.11 and bsd4 on pic32mx/mz, and I can tell you FreeRtos on an MCU and posix-like OS/or_linux are different worlds.
The overhead of linux/unix/posix_likeOS makes the stuff slow. Blinking LEDs via posix shell is one thing, driving/doing something at highest speed is something different.
Like: try to fly racing quadcopter controlled by RPi :)

acassis
Mon Sep 18, 2017 10:58 pm
Hi Roger,

My focus will be the RPi Zero W (with WiFi chip), but since the processor is the same the original RPi will be supported as well.


acassis
Mon Sep 18, 2017 11:09 pm
Hi Pito,

You are right. In fact there is an overhead, but it is really a small overhead. For example, the latency added to open a device file of a LED driver compared to directly driving the LED will be around 1us or less (depending on used microcontroller). Some projects are using NuttX like an ordinary RTOS (and violating its system layer), it is not the right thing to do. NuttX supports a High Performance / High Priority interruption logic, so you can write your ultra fast logic that will have priority over the system: http://www.nuttx.org/doku.php?id=wiki:n … ghperfints

In fact the Smoothie project is using this strategy to implement their new CNC/LaserCutter/3DPrinter control board:
https://github.com/Smoothieware/smoothie-v2


Pito
Tue Sep 19, 2017 9:33 am
I’ve created stm32f103ze_sram, configured for 512kB heap in external sram, changed the ld script, etc., it compiled into 41kB bin, flashed in. The led blinks, it prints out via UART, so basically it works! And I get fyi
up_assert: Assertion failed at file:irq/irq_unexpectedisr.c line: 65
up_dumpstate: sp: 20000c48
up_dumpstate: stack base: 20000d0c
up_dumpstate: stack size: 00000400
up_stackdump: 20000c40: 08009440 00000400 08009440 00000400 08009440 00000400 08009440 00000400
up_stackdump: 20000c60: 08009440 00000400 00000000 08001101 080010f1 08000b11 00000000 20000c90
up_stackdump: 20000c80: 68000000 00000003 00000008 0800037f 20000cd8 00000000 68000000 68000000
up_stackdump: 20000ca0: 00000003 00000008 00000000 00000000 00000000 00000000 20000780 68000008
up_stackdump: 20000cc0: 68080000 20000784 80000000 00080000 080033dc 01000000 2000026c 20000418
up_stackdump: 20000ce0: 00000003 00000000 0800372d 08005ad9 08000fc9 20000d10 0000f2f0 20000410
up_stackdump: 20000d00: 080003eb 0000156a ffffffff 0639e7f7 00000008 80000000 00000190 80000008
up_registerdump: R0: 20000780 68000008 68080000 20000784 68000000 68000000 00000003 00000008
up_registerdump: R8: 00000000 00000000 00000000 00000000 80000000 20000cd8 00080000 080033dc
up_registerdump: xPSR: 01000000 PRIMASK: 00000000 CONTROL: 00000000
up_assert: Assertion failed at file:irq/irq_unexpectedisr.c line: 65
up_dumpstate: sp: 20000c48
up_dumpstate: stack base: 20000d0c

RogerClark
Tue Sep 19, 2017 10:06 am
[Pito – Tue Sep 19, 2017 9:33 am] –

A nice stuff for upcoming long winter evenings (at least here in northern hemisphere).

Rapa Nui is in the southern hemisphere ;-)


acassis
Tue Sep 19, 2017 12:20 pm
[Pito – Tue Sep 19, 2017 9:33 am] –
I’ve created stm32f103ze_sram, configured for 512kB heap in external sram, changed the ld script, etc., it compiled into 41kB bin, flashed in. The led blinks, it prints out via UART, so basically it works! And I get fyi
up_assert: Assertion failed at file:irq/irq_unexpectedisr.c line: 65
up_dumpstate: sp: 20000c48
up_dumpstate: stack base: 20000d0c
up_dumpstate: stack size: 00000400
up_stackdump: 20000c40: 08009440 00000400 08009440 00000400 08009440 00000400 08009440 00000400
up_stackdump: 20000c60: 08009440 00000400 00000000 08001101 080010f1 08000b11 00000000 20000c90
up_stackdump: 20000c80: 68000000 00000003 00000008 0800037f 20000cd8 00000000 68000000 68000000
up_stackdump: 20000ca0: 00000003 00000008 00000000 00000000 00000000 00000000 20000780 68000008
up_stackdump: 20000cc0: 68080000 20000784 80000000 00080000 080033dc 01000000 2000026c 20000418
up_stackdump: 20000ce0: 00000003 00000000 0800372d 08005ad9 08000fc9 20000d10 0000f2f0 20000410
up_stackdump: 20000d00: 080003eb 0000156a ffffffff 0639e7f7 00000008 80000000 00000190 80000008
up_registerdump: R0: 20000780 68000008 68080000 20000784 68000000 68000000 00000003 00000008
up_registerdump: R8: 00000000 00000000 00000000 00000000 80000000 20000cd8 00080000 080033dc
up_registerdump: xPSR: 01000000 PRIMASK: 00000000 CONTROL: 00000000
up_assert: Assertion failed at file:irq/irq_unexpectedisr.c line: 65
up_dumpstate: sp: 20000c48
up_dumpstate: stack base: 20000d0c

Pito
Tue Sep 19, 2017 1:16 pm
Alan, when built for 103ZE only (default settings from 103min,btw I created a new config by search/replace all the stuff required in the entire stm32f103ze-sram folder, to be safe), it works
NuttShell (NSH)
nsh> free
total used free largest
Mem: 62208 10320 51888 51888
nsh>

acassis
Tue Sep 19, 2017 1:43 pm
[Pito – Tue Sep 19, 2017 1:16 pm] –
Alan, when built for 103ZE only (default settings from 103min,btw I created a new config by search/replace all the stuff required in the entire stm32f103ze-sram folder, to be safe), it works
NuttShell (NSH)
nsh> free
total used free largest
Mem: 62208 10320 51888 51888
nsh>

Pito
Tue Sep 19, 2017 2:58 pm
NuttShell (NSH)
nsh> free
total used free largest
Mem: 586496 10336 576160 524272
nsh>
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 null
crw-rw-rw- 0 ttyS0
nsh>nsh> echo Hello STM32DUINO World!
Hello STM32DUINO World!
nsh>
nsh> xd 20000000 256
Hex dump:
0000: 0a 00 00 01 00 00 05 00 00 00 01 00 00 00 00 00 ................
0010: 01 00 00 00 01 00 2f 00 ed 00 00 01 6c 00 00 20 ....../.....l..
0020: 01 00 48 00 47 00 00 01 6c 01 00 20 f4 92 00 08 ..H.G...l.. ....
0030: 00 00 00 20 00 00 00 00 00 00 00 00 a0 00 10 00 ... ............
0040: 00 08 00 00 00 c2 01 00 35 00 00 00 00 a2 4a 04 ........5.....J.
0050: 00 38 01 40 09 58 00 00 0a a0 00 00 88 96 00 08 [email protected]..........
0060: ff 00 01 00 01 00 00 00 3f 00 00 00 2e 2e 2e 2e ........?.......
0070: 2e 0d 0a 30 30 34 30 3a 20 30 30 20 30 38 20 30 ...0040: 00 08 0
0080: 20 2e 2e 2e 30 30 34 30 3a 20 30 30 20 30 38 20 ...0040: 00 08
0090: 30 0d 0a 30 30 38 30 3a 20 32 30 20 32 65 20 32 0..0080: 20 2e 2
00a0: 65 20 32 65 20 33 30 20 33 30 20 33 34 20 33 30 e 2e 30 30 34 30
00b0: 20 33 61 20 32 30 20 33 30 20 33 30 20 32 30 20 3a 20 30 30 20
00c0: 33 30 20 33 38 20 32 30 20 20 2e 2e 2e 30 30 34 30 38 20 ...004
00d0: 20 32 30 20 32 30 20 32 65 20 32 65 20 32 65 20 20 20 2e 2e 2e
00e0: 33 30 20 33 30 20 33 34 20 33 30 20 33 38 20 32 30 30 34 30 38 2
00f0: 30 20 20 2e 2e 2e 30 30 34 0d 0a 30 30 64 30 3a 0 ...004..00d0:
nsh>
nsh> xd 0x68000000 256
Hex dump:
0000: 08 00 00 00 00 00 00 80 f0 ff 07 00 08 00 00 00 ................
0010: 80 08 00 20 70 08 00 20 cd c2 01 f1 db d5 5c ca ... p.. ......\.
0020: db 4d 9b 4c 75 f5 42 60 2e b9 80 aa 46 ec 23 aa .M.Lu.B`....F.#.
0030: a9 db 05 a4 69 c9 a0 1c 26 83 7e 14 98 ca 37 57 ....i...&.~...7W
0040: 11 d9 cf df 56 7b ec 87 9f 90 a0 1d c5 19 16 03 ....V{..........
0050: 13 c2 2c 43 2d 06 54 01 db d7 4d d3 bc 64 67 bb ..,C-.T...M..dg.
0060: 74 e7 b2 21 42 19 43 5a aa 68 d7 25 be e5 95 63 t..!B.CZ.h.%...c
0070: 49 a3 5c 1b 5a 62 95 a6 f9 fa 59 11 98 27 22 3d I.\.Zb....Y..'"=
0080: 74 7f fb eb 5f c6 ad f4 ff 21 2c 22 25 0a 1b d4 t..._....!,"%...
0090: 6a 60 be a1 2e 0a 43 3f 7d 7d 8f 85 55 d3 78 eb j`....C?}}..U.x.
00a0: b7 7c df 9a ec dc 19 d6 7c a1 82 98 e9 8a 87 c0 .|......|.......
00b0: 36 2a e9 b2 00 2c e2 a3 93 5f b9 32 66 e5 b0 45 6*...,..._.2f..E
00c0: ef 61 7e 49 4e f4 c3 63 0b 1a 1f 21 38 90 99 40 .a~IN..c...!8..@
00d0: 03 91 91 7a 2c 98 44 3b 99 fd b6 ad 63 ba 7f 07 ...z,.D;....c...
00e0: b4 80 f7 14 67 7a f9 8c 2e d6 97 25 07 d9 48 5d ....gz.....%..H] 00f0: 53 4d 7b 9a 06 24 9d a0 f2 d0 87 79 7d ff 1e 72 SM{..$.....y}..r
nsh>

acassis
Tue Sep 19, 2017 10:36 pm
[Pito – Tue Sep 19, 2017 9:47 pm] –
36MHz SPI set:
nsh> dd if=/mnt/STM32Demo.bin of=/mnt/BBBBB
8388608 bytes copied, 0 msec, 152 KB/s
nsh>

Pito
Tue Sep 19, 2017 11:13 pm
Yeah, the filesystem performance over SPI (EDIT: NONE DMA) here is not the best. Needs finetuning, sure. I’ve tried to enable DMA with SPI, but it does not boot (perhaps it needs to be implemented in src). Here is the ramdisk performance – that should be the sdcard’s one :)
We may try with SDIO on F407 (SDIO socket there) later on.
Ramdisk size 256kB.
nsh> dd if=/dev/zero of=/rdisk/RRRRR.dat bs=1024 count=128
131072 bytes copied, 40 msec, 3276 KB/s
nsh> df
Block Number
Size Blocks Used Available Mounted on
32768 485936 168522 317414 /mnt
0 0 0 0 /proc
512 475 258 217 /rdisk
nsh>

Pito
Tue Sep 19, 2017 11:40 pm
For fun:
nsh> xd 20000000 65536 > /mnt/iram_dump.txt
nsh> ls -l /mnt
/mnt:
-rw-rw-rw- 290826 iram_dump.txt
..
nsh> cat /mnt/iram_dump.txt
Hex dump:
..
0080: fe 54 68 69 73 20 69 73 20 6e 6f 74 20 61 20 62 .This is not a b
0090: 6f 6f 74 61 62 6c 65 20 64 69 73 6b 2e 20 20 50 ootable disk. P
00a0: 6c 65 61 73 65 20 69 6e 73 65 72 74 20 61 20 62 lease insert a b
00b0: 6f 6f 74 61 62 6c 65 20 66 6c 6f 70 70 79 20 61 ootable floppy a
00c0: 6e 64 0d 0a 70 72 65 73 73 20 61 6e 79 20 6b 65 nd..press any ke
00d0: 79 20 74 6f 20 74 72 79 20 61 67 61 69 6e 20 2e y to try again .

Pito
Wed Sep 20, 2017 1:34 am
With SPI1 @36MHz and DMA1 for SPI1 enabled (Sandisk 16GB CL10):
nsh> dd if=/mnt/STM32Demo.bin of=/mnt/ZZZZZ
8388608 bytes copied, 37730 msec, 222 KB/s
nsh>
nsh> dd bs=1024 if=/mnt/CCCC.bin of=/mnt/QQQQ.bin
8388608 bytes copied, 25740 msec, 325 KB/s
nsh>
nsh> dd bs=2048 if=/mnt/CCCC.bin of=/mnt/SSSS.bin
8388608 bytes copied, 16930 msec, 495 KB/s
nsh>
nsh> dd bs=4096 if=/mnt/CCCC.bin of=/mnt/GGGG.bin
8388608 bytes copied, 12630 msec, 664 KB/s
nsh>
nsh> dd bs=8192 if=/mnt/CCCC.bin of=/mnt/DDDD.bin
8388608 bytes copied, 10730 msec, 781 KB/s
nsh>
nsh> dd bs=16384 if=/mnt/CCCC.bin of=/mnt/FFFF.bin
8388608 bytes copied, 10340 msec, 811 KB/s
nsh>
nsh> dd bs=32768 if=/mnt/CCCC.bin of=/mnt/EEEE.bin
8388608 bytes copied, 10230 msec, 820 KB/s
nsh>
nsh> dd if=/mnt/CCCC.bin of=/dev/null
8388608 bytes copied, 9990 msec, 839 KB/s
nsh>

zoomx
Wed Sep 20, 2017 10:40 am
[acassis – Tue Sep 19, 2017 3:39 pm] –
zoomx the right NuttX repository is this: https://bitbucket.org/nuttx/nuttx

Thanks! I just posted a link of a repository that seems to have an STM32F103 porting but I don’t know if it is up to date or even if it works.


acassis
Wed Sep 20, 2017 11:55 am
[Pito – Wed Sep 20, 2017 1:34 am] –
With SPI1 @36MHz and DMA1 for SPI1 enabled (Sandisk 16GB CL10):
nsh> dd if=/mnt/STM32Demo.bin of=/mnt/ZZZZZ
8388608 bytes copied, 37730 msec, 222 KB/s
nsh>
nsh> dd bs=1024 if=/mnt/CCCC.bin of=/mnt/QQQQ.bin
8388608 bytes copied, 25740 msec, 325 KB/s
nsh>
nsh> dd bs=2048 if=/mnt/CCCC.bin of=/mnt/SSSS.bin
8388608 bytes copied, 16930 msec, 495 KB/s
nsh>
nsh> dd bs=4096 if=/mnt/CCCC.bin of=/mnt/GGGG.bin
8388608 bytes copied, 12630 msec, 664 KB/s
nsh>
nsh> dd bs=8192 if=/mnt/CCCC.bin of=/mnt/DDDD.bin
8388608 bytes copied, 10730 msec, 781 KB/s
nsh>
nsh> dd bs=16384 if=/mnt/CCCC.bin of=/mnt/FFFF.bin
8388608 bytes copied, 10340 msec, 811 KB/s
nsh>
nsh> dd bs=32768 if=/mnt/CCCC.bin of=/mnt/EEEE.bin
8388608 bytes copied, 10230 msec, 820 KB/s
nsh>
nsh> dd if=/mnt/CCCC.bin of=/dev/null
8388608 bytes copied, 9990 msec, 839 KB/s
nsh>

acassis
Wed Sep 20, 2017 11:56 am
[zoomx – Wed Sep 20, 2017 10:40 am] –

[acassis – Tue Sep 19, 2017 3:39 pm] –
zoomx the right NuttX repository is this: https://bitbucket.org/nuttx/nuttx

Thanks! I just posted a link of a repository that seems to have an STM32F103 porting but I don’t know if it is up to date or even if it works.

Ah OK! There is a mirror at github, but it is other URL and AFAIK is not updated often.


Pito
Wed Sep 20, 2017 2:17 pm
Nice! Please try to copy from SDCard to RAMDISK, it should be an interesting test to do! ;-)
Here you are – the entire session such the people may try as well fast:
1. a ramdisk sized ~400kB created
2. an sdcard filesystem mounted
3. a TEST.bin file ~300kB created on the sdcard and then copied from/to the ramdisk
All done on STM32F103ZE @72MHz, 512kB 10ns Sram (A=0, D=1), SPI1(36MHz, DMA on), Sandisk 16GB CL10.
NuttShell (NSH)
No MOTD string provided
nsh> mkrd -m 1 -s 512 800
nsh> mkfatfs /dev/ram1
nsh> mount -t vfat /dev/ram1 /ramdisk
nsh> mount -t vfat /dev/mmcsd0 /sdcard
nsh>
nsh> df
Block Number
Size Blocks Used Available Mounted on
512 761 2 759 /ramdisk
32768 485936 169547 316389 /sdcard
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
brw-rw-rw- 0 mmcsd0
crw-rw-rw- 0 null
brw-rw-rw- 0 ram1
crw-rw-rw- 0 ttyS0
crw-rw-rw- 0 urandom
crw-rw-rw- 0 zero
nsh>
nsh> dd if=/dev/zero of=/sdcard/TEST.bin bs=1024 count=300
307200 bytes copied, 630 msec, 487 KB/s
nsh>
nsh> dd if=/sdcard/TEST.bin of=/ramdisk/AAAA.bin
307200 bytes copied, 370 msec, 830 KB/s
nsh>
nsh> dd if=/ramdisk/AAAA.bin of=/sdcard/OOOO.bin
307200 bytes copied, 980 msec, 313 KB/s
nsh>
nsh> time "cp /ramdisk/AAAA.bin /sdcard/WWWW.bin"
0.6800 sec
nsh>
nsh> rm /ramdisk/AAAA.bin
nsh> time "cp /sdcard/WWWW.bin /ramdisk/SSSS.bin"
0.3100 sec
nsh>
nsh> ls -l /ramdisk
/ramdisk:
-rw-rw-rw- 307200 SSSS.bin
nsh>

Pito
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!
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>

acassis
Wed Sep 20, 2017 6:32 pm
[Pito – 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!
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>

acassis
Wed Sep 20, 2017 11:32 pm
[Pito – 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!
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>

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:
Error: stm32x device protected


acassis
Fri Sep 22, 2017 11:39 am
[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:
Error: stm32x device protected


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).
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>

acassis
Thu Aug 30, 2018 6:51 pm
Hi @Pito,

Sorry I didn’t follow this thread further.

Yes, NuttX support SD/MMC hotplug/automounter.

You need to configure it mapping the interrupt CardDetection pin to mount the card automatically.


Leave a Reply

Your email address will not be published. Required fields are marked *