RetroBSD

2.11BSD operating system for microcontrollers
It is currently Tue Oct 15, 2019 12:07 pm

All times are UTC




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: STM32F4DISCOVERY
PostPosted: Sun Apr 08, 2012 9:30 pm 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
I was wondering how portable RetroBSD is in terms of different micro-controllers? I have an STM32F4DISCOVERY board, the chip has 192k of RAM and 1MB of flash, which is more than the PIC32. I built a gcc tool chain for it yesterday on my Mac, and compile NuttX, interesting, it has a shell but not as flexible as BSD.

Olimex have an interesting STM32F4 board coming out:

http://olimex.wordpress.com/2012/03/27/stm32-h407-board-design-complete/



Top
 Profile  
 
PostPosted: Sun Apr 08, 2012 9:50 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Unfortunately, the F4Disco has only 128kB ram from which you can run the code (the same as PIC32). The 64kB of CCM is good for buffers only (no DMA access as well to CCM). However, F4 is faster and has much lower power consumption than the PIC32 (F4 is made on 90nm, PIC32 on 180nm technology). With 144 pins F4 version you may connect a static ram easily to it (up to 64MBytes). The only way how to utilise the 192kB ram of the F4 is for example eLua (eLua interprets from a ram, it includes a mechanism for merging various ram segments).

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Apr 09, 2012 5:20 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
I think the Olimex STM32-H407 board will have the pins to attach external RAM like an Arduino shield. Well that's what they suggest in the blog thread on it.

I tried eLua on the STM32F4DISCOVERY, it's pretty good, nowhere near as flexible as RetroBSD, the command shell is really barren. Lua is a good scripting language though, pity it's rather large for micro-controllers. It wouldn't run on my STM32VLDISCOVERY. (Yeah I bought both, well the VL first then realize the F4 was way better and almost same price)


Top
 Profile  
 
PostPosted: Mon Apr 09, 2012 4:14 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
You may run chibios
http://www.chibios.org/dokuwiki/doku.php?id=start
..ready ports for stm32VLdisco and stm32F4disco. Works fine and fast on both.. The VL is easy to overclock, I am running two on 48MHz (one at 56MHz).
I've got few 2Mbytes/10ns srams for F4disco, but it would be better to elaborate the 144pin version so I stopped the ram-shield development for F4disco. Porting retrobsd to ARM would be a great move, of course..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 3:52 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
So far the only micro-controller cores I like are the MIPS and ARM specifically the PIC32 and STM32 series, I think they have the low cost market sewn up atm.

Assuming I have an ARM toolchain, which parts of the RetroBSD source are core specific? Is it just the stuff in the startup-mips directory? Specifically mcount.S
I don't understand the RetroBSD boot sequence. I will have to read the "Bach M.J. - The design of the UNIX operating system (1986)" book and see how the boot sequence goes.

I guess you need some sort of bootloader like the Duinomite has, is there such a thing for the STM32F4DISCOVERY? I have been programming it with the on board STLINK debugger, which I guess bypasses a bootloader.





Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 4:36 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
Found some more assembler files:

retrobsd/share/example/ashello.S
retrobsd/share/example/echo.S
retrobsd/src/libc/mips/gen/_setjmp.S
retrobsd/src/libc/mips/gen/htonl.S
retrobsd/src/libc/mips/gen/htons.S
retrobsd/src/libc/mips/gen/setjmp.S
retrobsd/src/libc/mips/gen/sigsetjmp.S
retrobsd/src/libc/mips/string/bcmp.S
retrobsd/src/libc/mips/string/bcopy.S
retrobsd/src/libc/mips/string/bzero.S
retrobsd/src/libc/mips/string/ffs.S
retrobsd/src/libc/mips/string/index.S
retrobsd/src/libc/mips/string/memcpy.S
retrobsd/src/libc/mips/string/memmove.S
retrobsd/src/libc/mips/string/memset.S
retrobsd/src/libc/mips/string/rindex.S
retrobsd/src/libc/mips/string/strcmp.S
retrobsd/src/libc/mips/string/strlen.S
retrobsd/src/libc/mips/sys/_brk.S
retrobsd/src/libc/mips/sys/_exit.S
retrobsd/src/libc/mips/sys/pipe.S
retrobsd/src/libc/mips/sys/ptrace.S
retrobsd/src/libc/mips/sys/sigaction.S
retrobsd/src/startup-mips/mcount.S
retrobsd/sys/pic32/startup.S

Is that all the MIPS specific stuff?


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 6:22 am 

Joined: Mon Mar 12, 2012 2:19 pm
Posts: 47
I'm skeptic STM32F4 processor can support memory protection facility. PIC32 is capable of partitioning SRAM and NOR flash into user assignment and kernel assignment. This makes possible the memory protection which RetroBSD relies upon. I found chflags command has a bug to make NULL pointer reference and ends up with a core dump file. It's a wonder as such the small microprocessor can do the right thing in UNIX manner.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 7:36 am 

Joined: Mon Mar 12, 2012 2:19 pm
Posts: 47
ernie,

The asm files are mostly system call stubs beside the very last one. What you have to do is to understand whether STM32 memory proctection unit can handle RetroBSD scheme, say, u0/u reside at kernel address space and user processes are not allowed to access privileged hardware resources.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 7:47 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
Not quite sure what you mean. I know the STM32F4 has a MPU, the description as follows:

"The memory protection unit (MPU) is used to manage the CPU accesses to memory to prevent one task to accidentally corrupt the memory or resources used by any other active task. This memory area is organized into up to 8 protected areas that can in turn be divided up into 8 subareas. The protection area sizes are between 32 bytes and the whole 4 gigabytes of addressable memory.
The MPU is especially helpful for applications where some critical or certified code has to be protected against the misbehavior of other tasks. It is usually managed by an RTOS (real- time operating system). If a program accesses a memory location that is prohibited by the MPU, the RTOS can detect it and take action. In an RTOS environment, the kernel can dynamically update the MPU area setting, based on the process to be executed.
The MPU is optional and can be bypassed for applications that do not need it."

Or do you mean something more fine grained that kicks in during a context switch?



Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 8:40 am 

Joined: Mon Mar 12, 2012 2:19 pm
Posts: 47
ernie,

It'd be helpful to understand how RetroBSD runs when you write down memory map described in sys/pic32/*/*.ld and src/elf32-mips.ld, and pursue the way STM32 memory protection unit can manage the case.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 10:36 am 

Joined: Mon Mar 12, 2012 2:19 pm
Posts: 47
Ok, let me rumble more,

Here is the TODO list of RetroBSD porting to a new CPU, in the order of significance.

1. define address space
*.ld files mentioned earlier are the fundamental parameters to define runtime environment. PIC32 has MIPS M4K code inside and its address space usage is more-or-less common across other MIPS SoC. ARM is not that case. It's necessary to research STM32 memory protection unit and how to compose address space for kernel and user process. It's a kind of stunning simplicity to see PIC32 uses only four (4) SoC registers to achieve the kernel/user partitioning (flash and SRAM). It's necessary to learn about how to program STM32 memory protection unit to make RetroBSD possible on ARM.

2. start.S and exception.c
The former provides the three things; reset entry point to dive into kernel main() before invoking /sbin/init at the return, exception entry and exit, context switch implemented as setjmp/longjmp pair. The latter is the place of central activity for ordinary runtime.

3. machdep.c
startup() is the routine called by main(). It prepares many things which vary on target CPU and SoC facilities. BMX... registers are to define partitioning. The rest of memory protection functionality is implemented by MIPS architecture itself and kernel needs no more code. This is another file to be heavily hacked by porting for other CPU/SoC.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 1:04 pm 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Oh great, finally we have ARM microcontroller, capable to run RetroBSD. IMHO, the first thing we need is a good simulator. I guess uARM, developed by Dmitry Grinberg, could be a starting point.

RetroBSD was developed with a portability in mind. Most of the kernel is architecture-independent (sys/kernel, sys/include). There is a small number of places, where a saved stack frame is directly referenced (look for u.u_frame) - it needs to be guarded by #ifdefs.

PIC32-related part of the kernel is placed in sys/pic32 directory. I would recommend to create sys/stm32 directory for this port. Some drivers, like SD card, console, GPIO or ADC probably could be moved to arch-independent place, say sys/drivers. Unfortunately, we cannot reuse USB stack (Microchip's copyright is too restrictive).

You can use sys/pic32/baremetal/Makefile configuration as a starting point, for simplicity. The challenge is to build a kernel, which can start and print a message on console. Copy a basic set of arch-dependent files from sys/pic32 to sys/stm32, and modify them (cpu.h, io.h, limits.h, machparam.h, startup.S, clock.c, cons.c, devsw.c, exception.c, machdep.c, mem.c, signal.c, sysctl.c). Design a memory map and create a linker script. All we need from MPU is to protect a kernel data region from the user programs.

Next step is to design a user/kernel API: how to pass args to syscalls and get returned data. This will help to build a syscall library (src/libc/thumb2/sys). All other assembler files can be ported from NetBSD or other sources.
--Serge


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 7:23 pm 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
What about this simulator, it's free for personal use and does cortex M3 and M4

http://www.ovpworld.org/download_CortexM.php

Runs on Linux and Windoze.


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 10:28 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
.. 128kB for user program, 64kB for kernel and other buffers (tcpip, video, etc), fast SDIO interface for SDcards, swapdevice via FSMC, up to 216MHz (overclocked) clock - it sounds promising :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Apr 11, 2012 4:47 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
Tsvetan from Olimex reckons their STM32-H407 should be available sometime next month. It has a boot loader to suit the Maple IDE which is an Arduino style IDE which makes sense as the board will take Arduino shields, not sure which compiler is underneath it.

http://www.kenseglerdesigns.com/cms/forums/viewtopic.php?f=14&t=497


Top
 Profile  
 
PostPosted: Wed Apr 11, 2012 11:14 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
OVPsim is a perfect simulator: architecturally exact and well documented. I use it a lot at work. No version for Mac, unfortunately. One needs to write a model of all STM32-specific peripherals for OVPsim.

_________________
--Serge


Top
 Profile  
 
PostPosted: Fri Apr 27, 2012 9:00 am 

Joined: Mon Mar 12, 2012 2:19 pm
Posts: 47
ernie,

Olimex posts a news telling the design progress of STM32-H407. It's quite impressive to know that it offers 4 set of 32-bit external device/SRAM bus. This makes possible to accommodate large SRAM/NOR/NAND or even LCD controller to hook there.

Regard to the possibility to port RetroBSD, I still have a reserve for it. I'm looking at STM32 PDF anticipating that this might be designed for threaded OS in mind not for process model OS.


Top
 Profile  
 
PostPosted: Fri Apr 27, 2012 10:36 am 

Joined: Sat Nov 10, 2012 1:18 pm
Posts: 27
SRAM hooks would be nice! What I like about the STM32-H407 is the arduino shield sockets, makes it very handy for tinkering.



Top
 Profile  
 
PostPosted: Wed Dec 05, 2012 10:11 am 

Joined: Wed Dec 05, 2012 3:51 am
Posts: 10
Serge, thank you for pointing me out this discussion. I started to work on an open hardware F4-DiscoverFree. This board will be used as robot controller and I'd like to see RetroBSD running on it. For beginner, I plan to port MPIDE which is familiar for Arduino fans.

http://www.aisenke.com/nodinorobotics/f ... ndex.shtml

What Pito pointed out regarding 128k RAM for user and 64k CC RAM for kernel is actually being used in F4OS project. I ported F4OS to F4-DiscoverFree and it works like charm. Base on this work, I'd like to try porting RetroBSD on F4-DiscoverFree. The board was designed carefully to include all features as possible, including on-board FT2232 JTAG + serial port connected to USART3 and USB micro-AB port (meaning that you can debug using JTAG and upload RetroBSD kernel through JTAG, built-in serial bootloader, or USD DFU as you like).

If everything works, RetroBSD will become my first official supported system on F4-DiscoverFree. Anyone care to help? I want my robots powered by RetroBSD!


Top
 Profile  
 
 Post subject: Re: STM32F4DISCOVERY
PostPosted: Thu Dec 06, 2012 3:09 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
You are welcome, Ekawahyu! :)
It would be great to have a port to STM32F4.
Do you use any simulator for the development?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission