DiscoBSD on Teensy 3.5 development board (NXP Kinetis K) #19
Replies: 7 comments 8 replies
-
Hey there, It seems that the Teensy 3.5 is out of production with no stock left from distributors (I checked pjrc.com, Mouser, and Digikey). I would very much like to architect the codebase to be able to support many more ports and targets, without blowing up the binary sizes. My current direction was on implementing support for ARMv6-M (Cortex-M0+) so that the Raspberry Pi Pico RP2040 can be supported. I heavily relied on the STM32F4 cube HAL and LL libraries for the stm32 port. Primarily, as I am familiar with them, and they are BSD licensed (hard requirement for inclusion), so there will be some work in generalizing the barrier between vendor code and kernel code in making the codebase able to support many ports and targets without getting unwieldy. How is the SD card driver coming along? |
Beta Was this translation helpful? Give feedback.
-
Hi, Given how the PJRC-written Teensy support code is laid out, getting this going on the current Teensy 4.x would probably be rather trivial. I might grab one from the upcoming sale. I used to participate a bit in NetBSD development more than 20 years ago so I am more or less aware of what you describe. SD driver works now, right now I'm past the first fork() and can turn off the onboard led from the userspace. However, I'm probably overwriting the USB UART buffers or other control data with something. I'll figure this out soon enough, will probably go find a TTL USB UART so that I can just use the hardware UART - I was lazy and just did a quick hack to get USB virtual UART console without having to go find the hardware equivalent. Debugging with proper tools would probably make the process faster, all I have are printf() and the LED. Here's what it says now, complete with all sorts of debug prints:
|
Beta Was this translation helpful? Give feedback.
-
Looks like my 5 am posting failed to contain things I meant to put in such as "thank you for encouragement and the code!" We are now deep in userspace, running into things like this:
Need to read up on the ARM fault types. The ARM documentation has been excellent so far - thorough and so far I at least think I've understood everything I've read. In general, this has been - and still is - a fun learning exercise. I do have some knowledge of similar concepts with other architectures but two weeks ago I knew nothing specific about ARM architecture other than "umm, it's a RISC so probably lots of registers" and my command of ARM assembly was limited to "does this thing accept LDA like 6510 did?" edit; the discrepancy between 256/192 and 255/191 kB of RAM is a funny one. Back when these chips were new, Freescale had an incredible lapse where they mistakenly described the MK64FX512 as having 192 kB of RAM and this had been stated as a fact in the chip-specific reference manual all that time[1]. So, because of a lot of code for these devices already existed out there, this was solved in Teensyverse so that [1] https://community.nxp.com/t5/Kinetis-Microcontrollers/What-addresses-map-to-SRAM-in-the-K64-sub-family/m-p/720301 |
Beta Was this translation helpful? Give feedback.
-
Almost there. Sorted out the alignment issues in the SD driver, possibly found a subtle bug in the IPL-to-ARM priority juggling and learned a lot about the kernel internals. Right now the quick'n'dirty nature of the USB console driver I wrote is starting to bite me. If I cause enough output after I envy people capable of working in a structured, professional manner. My method consists of creating chaos, then making sense of that chaos and, in the end, attempting to make everything look like there never was any chaos. edit; license-wise, I'll make a couple of confirmations but I believe everything I have in my tree is BSD, MIT or equivalent. Also, as a disclaimer and general rule, everything I write is MIT - has always been and will always be. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Multiuser with a small quirk - need to push the interrupt button twice to cause an interrupt and have the startup sequence proceed. I know what's wrong with it, need to fix it later tonight. Got a long weekend here because of a national holiday on Friday, this means good things for the port. How reliable are the UARTs with supported hardware? |
Beta Was this translation helpful? Give feedback.
-
Been running with MPU enabled for some time now. No idea how any of this would be done in the CMSISverse, but if nothing else, this could be thought of as an example of a configuration that is known to work. MPU is set up as the first thing in https://github.com/onre/discobsd/blob/master/sys/mk64/mpu.c It does prevent silly things like this one from crashing the system - instead a bus fault is printed on the console. Added the relevant MPU registers to fault.c, though there is still some cruft in there as well. I'm thinking of attempting to use the MPU for process isolation as it does support 8-bit process IDs for user mode, and with this config there are seven unused MPU regions left to configure. I paid for all of those regions. |
Beta Was this translation helpful? Give feedback.
-
I've got one of these:
https://www.pjrc.com/store/teensy35.html
I've been writing a toy OS for it but then I came across RetroBSD and then DiscoBSD. I figured that as the hard work here has already been done by others, it'd probably be pretty trivial to get it going on another Cortex-M based board, even if the peripherals differ a bit.
So, now I spent a long weekend mashing bits and pieces together, and got it to actually show some pretty strong signs of life. Thanks to both the Teensy support libraries and the
stm32
port of DiscoBSD being well structured and easy to read, this was actually rather easy to achieve.The exclamation mark is a debug print from an early bootup stage - I had somehow managed to skip a comment in the Teensy library sources about having to wait for a moment before the USB UART is actually ready to use.
Next I'll write a driver of some sort for the SD card and we'll see what happens then.
Beta Was this translation helpful? Give feedback.
All reactions