Falling down from FreeBSD
RubyKaigi2021
Hiroki Mori
@yamori813
FreeBSD support of small devices
FreeBSD remove support of some devices
armv4 support deleted before 12R
armv5 support deleted before 13R
Admtek SoCs support deleted before 12R
Realtek is too old MIPS version. So it can't be ported.
Older module resources
FreeBSD need more than 32M bytes of RAM and 8M bytes of flash
8MB RAM is too small for FreeBSD
2MB flash is too small for FreeBSD
Is it really garbage?
It's real 32Bit architecure
It have Ethernet support
Chip is not broken
Power consumption is low
Save the earth!
Let's reduce garbage dumping
Protect nature
We have not so much resources
Rare metal recycling is conspiracy
We have no time
So I started mruby on YABM
Lightweight ruby language
Developed with C language
Almost fully written by matsumoto-san(matz)
For Embedded target
compile to bytecode and execute
Extend by C or Ruby code, named mrbgems
Bare Metal port
Not use any OS
Directly executed from boot loader
YABM is Yet Another Bare Metal
Targets
Realtek RTL8196C,E... (Lexra:MIPS I)
Broadcom BCM4712...(MIPS 4K)
Admtek ADM5120(MIPS 4K)
Kinden KS8695(ARMV4)
FreeBSD have Broadcom/mips support. But still not support network.
How to get target
Japanese great second hands shop named “Hardoff” have so many target
Every city have “Hardoff” shop
Only 110 yen or 330 yen
How to build
Development environment
Linux ELF toolchain on FreeBSD Linux emulation
FreeBSD Cross compiler Collection package
all gcc is version 4
All target bootloader support tftp firmware upgrade
Not support float
Reuse ZRouter.org knowledge
Used libraries
newlib (only libc)
lwip
bearssl
Header is important
How to build
Flash image
Boot sequence
bootloader copy VM image to memory then ...
Support devices
Interrupt Timer
Ethernet GPIO
UART Flash
I2C by GPIO bitbang
Bootloader
RTL8196C - Original
BCM4712 - CFE
ADM5120 - u-boot
KS8695 - u-boot
some bootloader build on FreeBSD Linux emulation
MMU support
Not using MMU on a MIPS target
On ARM SoCs use MMU, because of performance issue
Very slow fibonaccci benchmark no MMU because of no cache
but only use single mapping one-to-one addresses
ethernet buffer use on no cache memory
IoT
Network Support
Ethernet driver code reference boot loader, Linux or FreeBSD
all target support TCP/IP and TLS by BearSSL
support DHCP or static IP
support NTP, HTTP and HTTPS
support IPv6
not support of MQTT
Internet of Test
ThingSpeak provide free plan
I made weather station used I2C sensor
update 20 sec interval
Part of Script
val = @y.i2cread(BMPADDR, addr) << 8 | @y.i2cread(BMPADDR, addr + 1)
para = "api_key=" + APIKEY + "&field1=" + count.to_s + "&field2=" + btstr + "&field3=" + bpstr
res = SimpleHttp.new("https", "api.thingspeak.com", 443).request("GET", "/update?" + para, {'User-Agent' => "test-agent"})
With mruby on FreeBSD
Ouchi monitor (omon)
Used mips small module
Build mruby by ZRouter ports.
mruby on YABM post data to
mruby on FreeBSD by HTTP
Let’s start
How do I do ?
Go HardOff
check Qiita
checkout source code from github
Source code
Thanks ray,matz,friend
yamori813@yahoo.co.jp