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 » 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

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

Re: NuttX on a BluePill

Post by 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.
Last edited by Pito on Mon Sep 18, 2017 6:00 pm, edited 1 time 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 » 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.

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

Re: NuttX on a BluePill

Post by 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
Last edited by Pito on Tue Sep 19, 2017 1:22 pm, edited 1 time 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 » 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.

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

Re: NuttX on a BluePill

Post by 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..
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 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 ;-)

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

Re: NuttX on a BluePill

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

User avatar
RogerClark
Posts: 7475
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:17 pm

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

Re: NuttX on a BluePill

Post by 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-
Last edited by acassis on Tue Sep 19, 2017 3:47 pm, edited 1 time in total.

Post Reply