NuttX on a BluePill

Anything not related to STM32
User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: NuttX on a BluePill

Post by RogerClark » Mon Sep 18, 2017 10:38 pm

@acassis

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

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

Re: NuttX on a BluePill

Post by 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 :)
Pukao Hats Cleaning Services Ltd.

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

Re: NuttX on a BluePill

Post by 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
Posts: 22
Joined: Mon Sep 18, 2017 3:27 pm

Re: NuttX on a BluePill

Post by 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

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

Re: NuttX on a BluePill

Post by 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

Code: Select all

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
This is for information how it does dumps. Nice. Maybe I've done a mistake somewhere :) A nice stuff for upcoming long winter evenings (at least here in northern hemisphere).
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: NuttX on a BluePill

Post by RogerClark » Tue Sep 19, 2017 10:06 am

Pito wrote:
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
Posts: 22
Joined: Mon Sep 18, 2017 3:27 pm

Re: NuttX on a BluePill

Post by acassis » Tue Sep 19, 2017 12:20 pm

Pito wrote:
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

Code: Select all

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
This is for information how it does dumps. Nice. Maybe I've done a mistake somewhere :) A nice stuff for upcoming long winter evenings (at least here in northern hemisphere).
Hi Pito,

Look, the PC is at 0x080033dc you can open the System.map file and discover what function it is at or use the arm-none-eabi-addr2line -e nuttx 0x080033dc. This page explains how you can analyze hardware fault: http://nuttx.org/doku.php?id=wiki:howto ... -hardfault

I think you are near to get it working!

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

Re: NuttX on a BluePill

Post by 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

Code: Select all

NuttShell (NSH)
nsh> free
             total       used       free    largest
Mem:         62208      10320      51888      51888
nsh>
When I add in menuconfig the FSMC interface, and set 2 memory regions, set start of the second Heap 0x68000000, set size 524288, compile, I get that panic. Do I need to mess with FSMC settings (regions/banks/timing), or it is set somehow for us already?

Update- all the FSMC stuff is missing in the stm32f103ze-sram folder, so it seems it must be done manually somehow..
So - 3 files and .h missing items must be added manually. Also mem region is set from 0x64.. that is bad :)
Last edited by Pito on Tue Sep 19, 2017 3:24 pm, edited 2 times in total.
Pukao Hats Cleaning Services Ltd.

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

Re: NuttX on a BluePill

Post by acassis » Tue Sep 19, 2017 1:43 pm

Pito wrote:
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

Code: Select all

NuttShell (NSH)
nsh> free
             total       used       free    largest
Mem:         62208      10320      51888      51888
nsh>
When I add in menuconfig the FSMC interface, and set 2 memory regions, set start of the second Heap 0x68000000, set size 524288, compile, I get that panic. Do I need to mess with FSMC settings (regions/banks/timing), or it is set somehow for us already?

Update- all the FSMC stuff is missing in the stm32f103ze-sram folder, so it seems it must be done manually somehow..
So - 3 files and .h missing items must be added manually. Also mem region is set from 0x64.. that is bad :)
Hi Pito, I never used the FSMC before, you I suggest you to ask for help at NuttX mailing list. I'm sure other people that already used it will try to help you.

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

Re: NuttX on a BluePill

Post by Pito » Tue Sep 19, 2017 2:58 pm

Code: Select all

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 .8.@.X..........
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>
:) Configured with 512kB heap from 0x68.. (BLUE 103ZET with 512kB sram installed).
Now, how to use the external sram for code execution.. :) Perhaps it could be used as a ramdisk too..
Pukao Hats Cleaning Services Ltd.

Post Reply