Hi Bernd,

On 11/2/20, Bernd Walter <ti...@cicely7.cicely.de> wrote:
sic
>
> Well, thiss is all weird.
> My Chip is a SAMD21E17A, so it has only 16k RAM.
> I had been using in in another project with my own IO code and NXFFS on
> an SPI flash (W25), but had to reduce stack sizes to have enough RAM
> for the NXFFS.

Well, 16KB is really the bottom line, you probably will face issues
because you are trying to add fancy things like json, etc. I don't
suggest people to use NuttX on MCUs with less than 32KB because at end
of the day they will want to add some other subsystem to their
firmware and things will not work well.

> This was with old NuttX code, shortly before the Apache change.
> This project runs on a similar board, but uses different IO.
> One of the IOs I need is the ADC and NuttX had no ADC support for the
> SAMD21 in the code I had been using, therefor I upgraded in that project.
> I'm running FreeBSD and had to work arround a few additional Linuxisms,
> like calling "make" from a shell script and expect it to be GNU make.
> Anyways - the board is tight on IO Pins and I have no UART left for
> console.

In the past NuttX had a better support to BSDs because we used to have
a contributor that was running OpenBSD. If you want to help to make
NuttX run better on FreeBSD and other, please submit a patch to fix
it. :-)

> I did all my debugging with gdb and a bunch of LEDs.
> This is the first part of my main routine:
> int
> main()
> {
>         tm16_init();
> //      // enable first digit as test
> //      for (;;) {
> //              tm16_setbmp(3, 0x01);
> //              usleep(100);
> //      }
> //
>         LED_data[STATUS_LED] = 1;
>         LED_data[ERROR_LED] = 1;
>         LED_out();
>         LED_out();
>         sleep(1);
>         LED_data[ERROR_LED] = 0;
>         LED_out();
>
>         boardctl(BOARDIOC_INIT, 0);
>
>         config_init();
>
>         serial_init();
>
> #ifdef CONFIG_SAMD2L2_ADCx
>         if (sam_adc_setup() < 0) {
>                 syslog(LOG_ERR, "Failed to initialize the ADC driver\n");
>         }
> #endif
> ...
>

Let's to ignore the fact you are violating the userspace/kernel layer.
Try to avoid doing it. Your application needs to use access the LEDs
using the USERLEDS support. There is an example to stm32f103-minimum
board.

> tm16_init is just bit bang, also LED_out(), which delivers data to the
> tm1653
> chip I'm using to drive the LEDs.
> config_init() tries to read json config file from NXFFS, which should have
> been

Instead using json, maybe you could use Inifile, please take a look on
FSUTILS_INIFILE. I think it will use less memory than JSON.

> mounted after boardctl.
> serial_init() is empty for later use.
> Up until sam_adc_setup gets called, /dev/null gets init, the via
> board_app_initialize() I mount procfs and my SPI flash.
> When sam_adc_setup() gets called somehow the inodes tables it searches in
> seem to be corrup, at least the result makes no sense for me, but I don't
> understand that code path and memory structures well enough yet.
> If I call sam_adc_setup() before boardctl() it does init, but fails to
> open later when I try to use it.
> Then I thought, lets reduce memory usage and don't mount the NXFFS for now.
> Without that (which also inits the SPI), it never returns from boardctl().
>

Try to use the Custom board late initialization, maybe it could help you.

Normally I prefer to do everything booting the NSH and calling my
application from its prompt, only when everything is working I change
the entry point to my application.

> I'm open for ideas.
> My current plan is to setup a Linux system and try plain NuttX on an
> Arduino Zero.
>

This should be a better idea because you will have 32KB of RAM. They
after getting it working you can remove not necessary features to
eventually get it working reliable on 16KB RAM.

In the past I got NuttX running on less than 2KB RAM, but it was a PoC
and all main subsystem were removed, including the VFS. It mean I was
violating the abstraction like you did! :-D

Look here: https://www.flickr.com/photos/79703543@N00/18013069041/sizes/h/

See the usage RAM from the 'free' command.

BR,

Alan

Reply via email to