Giter Club home page Giter Club logo

chettrick / discobsd Goto Github PK

View Code? Open in Web Editor NEW
172.0 10.0 15.0 68.53 MB

2.11BSD-based UNIX-like OS for STM32 and PIC32 Microcontrollers

Home Page: http://www.DiscoBSD.org

License: BSD 3-Clause "New" or "Revised" License

Makefile 2.00% Shell 0.20% C 83.34% Assembly 0.57% Forth 0.70% Scheme 0.02% Roff 11.49% Yacc 0.98% Lex 0.31% HTML 0.17% M4 0.08% CSS 0.03% Brainfuck 0.01% Awk 0.03% Perl 0.03% Modelica 0.01% sed 0.01% Logos 0.01% Python 0.02% BASIC 0.02%
211bsd arm bsd c cortex-m embedded microcontroller operating-system pic32 stm32

discobsd's Introduction

DiscoBSD

2.11BSD-based UNIX-like Operating System for STM32 and PIC32 Microcontrollers

DiscoBSD is a 2.11BSD-based UNIX-like operating system for microcontrollers, with a focus on high portability to memory constrained devices without a memory management unit.

The current and third official release of DiscoBSD is DiscoBSD 2.2, released on February 29, 2024.

This microcontroller-focused operating system is an independent continuation of RetroBSD, a 2.11BSD-based OS targeting the MIPS-based PIC32MX7. DiscoBSD is multi-platform, as it also supports Arm Cortex-M4 STM32F4 devices.

Source code to the system is freely available under a BSD-like license.

History

DiscoBSD began as an undergraduate Directed Study in the winter of 2020 at the University of Victoria, Canada, as a case study of RetroBSD to port the operating system to the Arm Cortex-M4 architecture, and to enable portabilty in the hosting environment and target architectures and platforms. The paper Porting the Unix Kernel details this initial porting effort.

Work on DiscoBSD has progressed in earnest since the completion of the Directed Study, with the DiscoBSD/stm32 port booting multi-user in August 2022. The system is quite usable on supported development boards.

And work continues...

DiscoBSD Resource Requirements

A basic, minimal system uses 128 Kbytes of flash and 128 Kbytes of RAM.

The kernel is loaded into the flash and only uses 32 Kbytes of RAM. User programs each use the remaining 96 Kbytes of RAM, via swapping. Devices with more RAM can be used to run larger user programs.

An SD card, at least 512 Mbytes in size, is required for the root file system.

Installing and Running

Installation consists of loading the kernel into the microcontroller's flash memory, and imaging the SD card with the file sdcard.img.

The make target installfs uses the dd utility to image the SD card attached to the host operating system at SDCARD, such as /dev/rsdXc or /dev/sdX or /dev/rdiskX, replacing X with the actual drive number or letter, as the case may be.

For example, imaging an SD card attached at sd2 on an OpenBSD host operating system through the raw i/o device:

$ SDCARD=/dev/rsd2c make installfs

Communication with the DiscoBSD console requires a serial port. A USB to TTL device or the built-in VCP USB serial port on development boards can be used.

$ cu -l /dev/cuaU0 -s 115200

Depending on the host system, other serial port utilities such as screen, minicom, putty, or teraterm may be used.

Log in to DiscoBSD with user root and a blank password. Shutdown DiscoBSD with the halt, shutdown, or reboot commands.

Manual pages for commands are available through the man command.

Building

DiscoBSD is cross-built on UNIX-like host operating systems.

Currently supported host operating systems: OpenBSD, Linux, FreeBSD.

Instructions to configure an OpenBSD host development environment for Arm and MIPS targets is available here.

The build system fully supports both BSD make and GNU make.

From the source tree root, run:

$ make

which will build a file system image in the file distrib/stm32/sdcard.img and ELF-formatted kernels in the files sys/stm32/${BOARD}/unix.

DiscoBSD/stm32 is the default port, but DiscoBSD/pic32 may be built via:

$ make MACHINE=pic32 MACHINE_ARCH=mips

which will build a file system image in the file distrib/pic32/sdcard.img and ELF-formatted kernels in the files sys/pic32/${BOARD}/unix and Intel HEX-formatted kernels in the files sys/pic32/${BOARD}/unix.hex.

Using BSD make on a FreeBSD host requires the system makefile include directory to be specified on the command line or via the MAKESYSPATH environment variable. For example:

$ make -m /usr/share/mk

or

$ MAKESYSPATH=/usr/share/mk
$ export MAKESYSPATH

$ make

Debugging

DiscoBSD/stm32 is debugged through OpenOCD and GDB. The make targets for debugging are ocd and gdb-ocd.

Debug a particular development board via:

$ BOARD=f412gdisco make ocd

in one terminal, and:

$ BOARD=f412gdisco make gdb-ocd

in another terminal.

Additional Information

Port-specific information can be found in distrib/${MACHINE}/README.md for stm32 and pic32.

DiscoBSD/stm32 dmesg

DiscoBSD 2.2 (F412GDISCO) #1 502: Thu Feb 29 22:06:34 MST 2024
     [email protected]:/sys/stm32/f412gdisco
cpu: STM32F412xx rev C, 100 MHz, bus 50 MHz
oscillator: phase-locked loop, clock source: high speed external
uart2: pins tx=PA2/rx=PA3, af=7, console
sd0: port sdio0
sd0: type SDHC, size 31178752 kbytes
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 204800 kbytes
phys mem  = 256 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
Automatic boot in progress: starting file system checks.
/dev/sd0a: 1463 files, 12037 used, 191962 free
/dev/sd0c: 3 files, 3 used, 203996 free
Updating motd... done
Starting daemons: update cron 
Thu Feb 29 22:06:34 MST 2024


2.11 BSD UNIX (name.my.domain) (console)

login: root
Password:
DiscoBSD 2.2 (F412GDISCO) #1 502: Thu Feb 29 22:06:34 MST 2024

Welcome to DiscoBSD.

erase ^?, kill ^U, intr ^C
# 

DiscoBSD/pic32 dmesg

DiscoBSD 2.2 (MAX32) #1 502: Thu Feb 29 22:06:34 MST 2024
     [email protected]:/sys/pic32/max32
cpu: 795F512L 80 MHz, bus 80 MHz
oscillator: HS crystal, PLL div 1:2 mult x20
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart1: pins rx=RF2/tx=RF8, interrupts 26/27/28, console
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42
uart4: pins rx=RD14/tx=RD15, interrupts 67/68/69
sd0: port spi2, pin cs=RC14
gpio0: portA, pins ii---ii-iiiioiii
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins i-ii-------iiii-
gpio3: portD, pins --iiiiiiiiiiiiii
gpio4: portE, pins ------iiiiiiiiii
gpio5: portF, pins --ii--------i-ii
gpio6: portG, pins iiii--i-----iiii
adc: 15 channels
pwm: 5 channels
sd0: type I, size 348160 kbytes, speed 10 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 204800 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
Automatic boot in progress: starting file system checks.
/dev/sd0a: 1469 files, 12328 used, 191671 free
/dev/sd0c: 3 files, 3 used, 203996 free
Updating motd... done
Starting daemons: update cron 
Thu Feb 29 22:06:34 MST 2024


2.11 BSD UNIX (name.my.domain) (console)

login: root
Password:
DiscoBSD 2.2 (MAX32) #1 502: Thu Feb 29 22:06:34 MST 2024

Welcome to DiscoBSD.

erase ^?, kill ^U, intr ^C
# 

discobsd's People

Contributors

amarkee avatar chettrick avatar lhondareyte avatar saper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discobsd's Issues

Support inexpensive WeAct Studio STM32F4 Core boards

There is a new (?) cheap board family available via aliexpress, which could be a nice candidate for porting.

It is sold under the name "WeAct STM32F405RGT6 STM32F412RET6 STM32F446RET6 STM32F405 STM32F412 STM32F446 STM32F4 STM32 Core Board Demo Board Micropython" and it is sold under US$5.

Please consider to port DiscoBSD to this board.

Specs:

STM32F412RET6

STM32 Dynamic Efficiency MCU with BAM, High-performance and DSP with FPU, Arm Cortex-M4 MCU with 512 Kbytes of Flash memory, 100 MHz CPU, Art Accelerator, DFSDM

STM32F446RET6

High-performance foundation line, Arm Cortex-M4 core with DSP and FPU, 512 Kbytes of Flash memory, 180 MHz CPU, ART Accelerator, Dual QSPI

STM32F405RGT6

High-performance foundation line, Arm Cortex-M4 core with DSP and FPU, 1 Mbyte of Flash memory, 168 MHz CPU, ART Accelerator

DataLink

https://github.com/WeActStudio/WeActStudio.STM32F4_64Pin_CoreBoard.git


There are other alternative boards from the same company, the "WeAct STM32H723VGT6 STM32H723 STM32H7 STM32 Core Board Demo Board" looks pretty nice aswell

atc won't build

Hi,

I'm having difficulty building DiscoBSD because this builds /games/atc, which fails on my system.

Here is the some of the output of gmake

gmake -C atc -w
gmake[2]: Entering directory '/home/sam/proj/discobsd/games/atc'
/usr/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mabi=aapcs -mlittle-endian -mthumb -mfloat-abi=soft -nostdinc -I/home/sam/proj/discobsd/include  -N -nostartfiles -fno-dwarf2-cfi-asm -T/home/sam/proj/discobsd/lib/elf32-arm.ld /home/sam/proj/discobsd/lib/crt0.o -L/home/sam/proj/discobsd/lib -o atc.elf extern.o grammar.o input.o lex.o list.o log.o main.o tunable.o graphics.o update.o -lm -lcurses -ltermcap -lc
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libm.a(sqrt.o):(.bss+0x0): multiple definition of `errno'; /home/sam/proj/discobsd/lib/libm.a(asin.o):(.bss+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libcurses.a(cr_put.o):(.bss+0x18): multiple definition of `_win'; /home/sam/proj/discobsd/lib/libcurses.a(refresh.o):(.bss+0x4): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x50): multiple definition of `BC'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x104): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tgoto.o):(.bss+0x4c): multiple definition of `UP'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x3c): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x2): multiple definition of `PC'; /home/sam/proj/discobsd/lib/libcurses.a(curses.o):(.bss+0x10): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libtermcap.a(tputs.o):(.bss+0x0): multiple definition of `ospeed'; /home/sam/proj/discobsd/lib/libcurses.a(cr_tty.o):(.data+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /home/sam/proj/discobsd/lib/libc.a(exit.o):(.bss+0xc): multiple definition of `errno'; /home/sam/proj/discobsd/lib/libm.a(asin.o):(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
gmake[2]: *** [Makefile:25: atc] Error 1
gmake[2]: Leaving directory '/home/sam/proj/discobsd/games/atc'
gmake[1]: *** [Makefile:19: atc] Error 2
gmake[1]: Leaving directory '/home/sam/proj/discobsd/games'
gmake: *** [Makefile:52: all] Error 2

I can see that /sbin/fsck is having a similar problem. But I can't paste the full output of gmake here since there's a 64K limit.

I imagine this means that linking works a little differently on my system. As you know I fixed another game on that pull request.

Maybe atc and others need to be fixed in the same way, or maybe there's a flag or something I can set. I'd be interested to know what to do! I'm happy to file more pull requests as and when I figure it out if that's what you'd like.

sd0: no SD/MMC card detected on F4DISCOVERY

Hello,
On a F4DICOVERY, sd card is not detected, with this message:

2.11 BSD UNIX for STM32, rev G290 #6: Thu Feb 23 17:23:34 CET 2023
     luc@unxbox:/home/luc/discobsd/sys/stm32/f4discovery
cpu: STM32F407xx rev VGT6, 168 MHz, bus 48 MHz
oscillator: phase-locked loop, clock source: high speed external
uart2: pins tx=PA2/rx=PA3, af=7, console
sd0: port spi2
sd0: cannot open spi2 port
sd0: no SD/MMC card detected
panic: No root filesystem found!
no fs on dev (0,1)
syncing disks... done
halted
press any key to reboot...

I am using this adapter connected as follow:

    CS    <-   PB12
   SCK    <-   PB13
  MISO    ->   PB14
  MOSI    <-   PB15

The SD card is a lexar 16Go.
Any help will be apprecied.

kconfig: /usr/bin/ld: multiple definition of `debugging`

This is gcc 11.3.1 on Almalinux 9, GNU ld 2.35.2

same with gcc 11 on FreeBSD

make[2]: Entering directory '/home/saper/src/discobsd/tools/kconfig'
gcc -g  -o kconfig config.o main.o lang.o mkioconf.o mkmakefile.o mkswapconf.o 
/usr/bin/ld: main.o:/home/saper/src/discobsd/tools/kconfig/config.h:180: multiple definition of `debugging'; config.o:/home/saper/src/discobsd/tools/kconfig/config.h:180: first defined here
/usr/bin/ld: main.o:/home/saper/src/discobsd/tools/kconfig/config.h:171: multiple definition of `dtab'; config.o:/home/saper/src/discobsd/tools/kconfig/config.h:171: first defined here
/usr/bin/ld: main.o:/home/saper/src/discobsd/tools/kconfig/config.h:176: multiple definition of `conf_list'; config.o:/home/saper/src/discobsd/tools/kconfig/config.h:176: first defined here

I fixed this with the following for now:

diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile
index 42cb1cb..2b0eb56 100644
--- a/tools/kconfig/Makefile
+++ b/tools/kconfig/Makefile
@@ -1,5 +1,6 @@
 CC             = gcc -g
 CFLAGS         = -O -Wall -Werror
+LDFLAGS                = -z muldefs
 
 _HOST_OSNAME!= uname -s
 

but I think this is not a best change probably a linker script might be needed here...

share/zoneinfo: use gcc

When building on FreeBSD 14, "cc" is clang 16. This makes the build fail like this:

cd zoneinfo; make  
cc  -O -g -Wall -Werror -idirafter /big/sw/discobsd/include -c zdump.c -o zdump.o
zdump.c:26:1: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
show(zone, t, v)
^
zdump.c:48:1: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
readerr(fp, progname, filename)
^
zdump.c:61:1: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
tzdecode(codep)
^
zdump.c:74:1: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
main(argc, argv)
^
4 errors generated.

quick fix is this:

diff --git a/share/zoneinfo/Makefile b/share/zoneinfo/Makefile
index 7cfd33b..82ed5d9 100644
--- a/share/zoneinfo/Makefile
+++ b/share/zoneinfo/Makefile
@@ -20,7 +20,7 @@ LOCALTIME=    US/Pacific
 
 CFLAGS= -O
 LINTFLAGS=     -phbaxc
-CC=            cc
+CC=            gcc
 CFLAGS+=       -g -Wall -Werror -idirafter $(TOPSRC)/include
 
 TZCSRCS=       zic.c scheck.c ialloc.c

Instead, I could also add -Wno-deprecated-non-prototype but to CFLAGS, but not all compilers might know this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.