-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
targets: add implementation for Tillitis TKey device #4631
Conversation
Size difference with the dev branch: Binary size differenceflash ram before after diff before after diff 16716 16716 0 0.00% 4172 4172 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650 61472 61472 0 0.00% 6180 6180 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go 9568 9568 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go 13568 13568 0 0.00% 6788 6788 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx 8680 8680 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go 11884 11884 0 0.00% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go 9760 9760 0 0.00% 4752 4752 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go 8368 8368 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go 8124 8124 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go 7432 7432 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go 70632 70632 0 0.00% 3660 3660 0 0.00% tinygo build -size short -o ./build/test.hex -target=pinetime ./examples/bma42x/main.go 64012 64012 0 0.00% 6196 6196 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go 27412 27412 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go 64072 64072 0 0.00% 6228 6228 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go 12200 12200 0 0.00% 4812 4812 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go 8176 8176 0 0.00% 3344 3344 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go 22216 22216 0 0.00% 3540 3540 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go 69768 69768 0 0.00% 6368 6368 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/main.go 4620 4620 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go 69304 69304 0 0.00% 6968 6968 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi 65644 65644 0 0.00% 9004 9004 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi 7212 7212 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go 67628 67628 0 0.00% 6360 6360 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go 68164 68164 0 0.00% 6504 6504 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go 7872 7872 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go 5832 5832 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go 5784 5784 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go 10528 10528 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go 14808 14808 0 0.00% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go 16148 16148 0 0.00% 2360 2360 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go 10152 10152 0 0.00% 6916 6916 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic 10644 10644 0 0.00% 4868 4868 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic 29508 29508 0 0.00% 38076 38076 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing 10172 10172 0 0.00% 6916 6916 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll 10732 10732 0 0.00% 4868 4868 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll 263712 263712 0 0.00% 46748 46748 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow 11732 11732 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go 14152 14152 0 0.00% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go 26132 26132 0 0.00% 2328 2328 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go 12448 12448 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go 10744 10744 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go 9920 9920 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go 10372 10372 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go 9780 9780 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go 68656 68656 0 0.00% 6188 6188 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go 27224 27224 0 0.00% 3632 3632 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go 26944 26944 0 0.00% 5680 5680 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go 8240 8240 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go 8148 8148 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go 75640 75640 0 0.00% 7448 7448 0 0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go 12256 12256 0 0.00% 3352 3352 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go 6228 6228 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go 5260 5260 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go 10540 10540 0 0.00% 3328 3328 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw 2825 2825 0 0.00% 558 558 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo 13772 13772 0 0.00% 3400 3400 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sgp30 8080 8080 0 0.00% 6788 6788 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go 57476 57476 0 0.00% 3684 3684 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go 57532 57532 0 0.00% 3692 3692 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go 57448 57448 0 0.00% 3684 3684 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go 6688 6688 0 0.00% 2288 2288 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/i2c_128x32/main.go 6140 6140 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/spi_128x64/main.go 5844 5844 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go 6788 6788 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go 6700 6700 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go 16964 16964 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go 10604 10604 0 0.00% 4540 4540 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone 10064 10064 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go 10872 10872 0 0.00% 3340 3340 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive 9524 9524 0 0.00% 6780 6780 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go 12596 12596 0 0.00% 6976 6976 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go 14980 14980 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go 13460 13460 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go 24616 24616 0 0.00% 13720 13720 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go 6488 6488 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go 6176 6176 0 0.00% 2312 2312 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go 6400 6400 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go 26140 26140 0 0.00% 16412 16412 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go 6848 6848 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812 5764 5764 0 0.00% 9522 9522 0 0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-c3 ./examples/ws2812 62532 62532 0 0.00% 5952 5952 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go 1581 1581 0 0.00% 598 598 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/ws2812 1056 1056 0 0.00% 180 180 0 0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812 31856 31856 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go 16436 16436 0 0.00% 4724 4724 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go 11080 11080 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go 12788 12788 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go 6752 6752 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go 8664 8664 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go 6720 6720 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go 9276 9276 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go 7336 7336 0 0.00% 3316 3316 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go 7012 7012 0 0.00% 2268 2268 0 0.00% tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go 13004 13004 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go 8876 8876 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go 77348 77348 0 0.00% 6336 6336 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go 36584 36584 0 0.00% 3988 3988 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/ 71368 71368 0 0.00% 6336 6336 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/ 7276 7276 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/ 70904 70904 0 0.00% 6332 6332 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/ 71328 71328 0 0.00% 6344 6344 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/ 12188 12188 0 0.00% 3304 3304 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go 10812 10812 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/ 8744 8744 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go 13196 13196 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go 9308 9308 0 0.00% 5240 5240 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go 72756 72756 0 0.00% 10748 10748 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/ 61608 61608 0 0.00% 8232 8232 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/ 10296 10296 0 0.00% 6788 6788 0 0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/ 9032 9032 0 0.00% 3276 3276 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go 13308 13308 0 0.00% 4928 4928 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/ 31312 31312 0 0.00% 4540 4540 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go 11260 11260 0 0.00% 4252 4252 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go 12000 12000 0 0.00% 3324 3324 0 0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go 10440 10440 0 0.00% 3356 3356 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go 8552 8552 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go 9664 9664 0 0.00% 4764 4764 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go 82764 82764 0 0.00% 6576 6576 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/ 15920 15920 0 0.00% 4868 4868 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go 9892 9892 0 0.00% 3296 3296 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go 7808 7808 0 0.00% 4740 4740 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go 66928 66928 0 0.00% 4816 4816 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go 62364 62364 0 0.00% 3780 3780 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go 65348 65348 0 0.00% 6252 6252 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go 9320 9320 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go 11400 11400 0 0.00% 3324 3324 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi 8460 8460 0 0.00% 3760 3760 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt 65888 65888 0 0.00% 4784 4784 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go 85988 85988 0 0.00% 5140 5140 0 0.00% tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/ 296180 296180 0 0.00% 13776 13776 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal -stack-size 8kb ./examples/net/http-get/ 118864 118864 0 0.00% 7832 7832 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 -stack-size 8kb ./examples/net/tcpclient/ 244988 244988 0 0.00% 10476 10476 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/websocket/dial/ 102760 102760 0 0.00% 9808 9808 0 0.00% tinygo build -size short -o ./build/test.hex -target=metro-m4-airlift -stack-size 8kb ./examples/net/socket/ 338132 338132 0 0.00% 15352 15352 0 0.00% tinygo build -size short -o ./build/test.hex -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic/ 111092 111092 0 0.00% 7764 7764 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-mkrwifi1010 -stack-size 8kb ./examples/net/tlsclient/ 153720 153720 0 0.00% 6540 6540 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/mqttclient/natiu/ 116688 116688 0 0.00% 13124 13124 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/ 285876 285876 0 0.00% 17804 17804 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/ 286756 286756 0 0.00% 18192 18192 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/ 5329118 5329118 0 0.00% 810370 810370 0 0.00% |
UPDATE: I have added the UART support, so now the $ tinygo flash -size short -target=tkey examples/serial
code data bss | flash ram
428 0 2080 | 428 2080
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo1965928096/main.bin onto device
$ tinygo monitor -baudrate=62500
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
hell
hello world!
hello world!
hello world!
hello world! Note that the baud rate is fixed at 62500 and cannot be easily changed. See tillitis/tillitis-key1#288 |
FURTHER UPDATE: now added $ tinygo flash -size short -target=tkey examples/button
code data bss | flash ram
312 0 2084 | 312 2084
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo874847465/main.bin onto device |
YET FURTHER UPDATE: have now implemented the RNG interface, so the following works: $ tinygo flash -size short -target=tkey examples/rand
code data bss | flash ram
11756 56 2076 | 11812 2132
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo2643520006/main.bin onto device
$ tinygo monitor -baudrate=62500
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
4d0a0ab1fdaea355bc5a4a755770fa085dc12c83eea81043062edd43a4d754fb
f3d709ce9ed4f246ae79730a56bf40f827c84ce15e02e8fec2bcaa037e79799e
c878e6bae7c1283ccae4d9198b7ac7320e4e4482beed24250601a362e5a23c12
7879cb8d916dd0222c1b3d4054fb37dce2be0b33e60719f24c2be7edee9617a6
5c88b3e2de8e10ef9087e418d89e755ac0c6ca68f9ea49cc850f25638e4bdcc3
e8bcf6ab894a9366d4c224eeabe484da0c1c9f77f94bb22243c8204f0ac5c350
3e6707a530606a472c12bf7c6b180e9c786c78f3dff3291e7af962d28f017cb3
4bd4bdc231a4ead00ed726c68e173bdbb07966045acc7b509638d6949f4db8de
0dd34b3f408ffef9be126e649dd0a91a22231f998c7054e054053c7178aab64b |
Added commit from the weekend to conform to The $ tinygo flash -size short -target=tkey examples/echo
code data bss | flash ram
1060 0 2088 | 1060 2088
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo2398999357/main.bin onto device
$ tinygo monitor -baudrate=62500
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
Echo console enabled. Type something then press enter:
hello from TKey!
You typed: hello from TKey! |
targets/tkey.ld
Outdated
. = ALIGN(4); | ||
} >RAM | ||
|
||
/* Put the stack at the bottom of RAM, so that the application will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says the stack is at bottom of RAM. But it's above the beginning of .text. If it's growing downwards as usual doesn't it corrupt the loaded device app code? Is there some protection for every use that stops this from happening?
If you truly want the stack to occupy the first part of the bottom of RAM you will need either cooperation from firmware to begin load and execution at a higher address (incidentally, this was just what the TKey firmware did previously), or include some kind of jump instruction among the first instructions that is safe to be overwritten by later stack operations, not include the entire .text before the stack. Something like this layout of the device binary:
- _start: jump to crt0
- reserved space for stack
- crt0
- rest of .text
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation is valid only for the pre-allocated stack size. So you think it is better to allocate it before the .text
section? @aykevl any thoughts on this?
As the link script comment mentions, the application will crash on stack overflow instead of silently corrupting memory, so that is no protection, but it does tell you it has happened. Allocation of a larger initial stack is controlled via the stack-size
param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it will likely crash when the stack starts to write over the application. Eventually, it's likely to crash. I didn't realize that the intention was to noisily crash by just happening to try to execute some random data from the stack. I thought you just wanted to have the stack stop growing by stopping at the bottom of RAM.
A noisy crash like that is extra interesting in the TKey because that will most likely trigger the unimplemented instruction trap in the CPU and start blinking the status LED in red by the hardware design, only breakable by a power cycle.
A write outside of memory, at least from some early serial number, should also trigger that blink-red-forever hardware behaviour according to documentation but I need to verify that.
If true, that means placing the stack at the true bottom and writing outside of RAM should immediately halt the CPU on the TKey in a visible way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If true, that means placing the stack at the true bottom and writing outside of RAM should immediately halt the CPU on the TKey in a visible way.
With heap allocations, this is exactly the current behavior provided by the code in this branch.
For example, this code:
package main
import (
"runtime"
"time"
)
func main() {
ms := runtime.MemStats{}
runtime.ReadMemStats(&ms)
println("Starting Heap Used: ", ms.HeapInuse)
big := make([]byte, 8192)
for i := 1; i < len(big); i++ {
big[i] = big[i-1] + 1
}
for {
runtime.ReadMemStats(&ms)
println("Heap Used: ", ms.HeapInuse)
b := more()
big = append(big, b...)
time.Sleep(10 * time.Millisecond)
}
}
func more() []byte {
big := make([]byte, 8192)
for i := 1; i < len(big); i++ {
big[i] = big[i-1] + 1
}
return big
}
When flashed, produces the expected blinking red LED and also outputs panic data via connected serial port:
$ tinygo flash -size short -target tkey -monitor -baudrate 62500 crashme.go
code data bss | flash ram
2096 0 2076 | 2096 2076
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo338584284/main.bin onto device
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
Starting Heap Used: 0
Heap Used: 8192
Heap Used: 49152
Heap Used: 57344
Heap Used: 65536
panic: runtime error at 0x40000790: out of memory
[tinygo: panic at /home/ron/Development/tinygo/tinygo-122/src/runtime/slice.go:57:14]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says the stack is at bottom of RAM. But it's above the beginning of .text. If it's growing downwards as usual doesn't it corrupt the loaded device app code?
Indeed.
I think the simplest fix would be to move .stack
to just after .text.init
but before .text
. The .text.init
section is not needed anymore after init and can be freely overwritten.
I didn't realize that the intention was to noisily crash by just happening to try to execute some random data from the stack. I thought you just wanted to have the stack stop growing by stopping at the bottom of RAM.
The comment comes from Cortex-M targets, where we generally place the stack at the bottom of RAM which will generally lead to a crash when reading/writing there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested overflow of the stack using the following code:
package main
func fibonacci() func() int {
first, second := 0, 1
return func() int {
ret := first
first, second = second, first+second
return ret
}
}
func main() {
f := fibonacci()
for i := 0; i < 10; i++ {
println(f())
}
}
It appears to work as desired:
$ tinygo flash -size full -target tkey -monitor -baudrate 62500 fib.go
code rodata data bss | flash ram | package
------------------------------- | --------------- | -------
158 0 0 0 | 158 0 | (unknown)
398 0 0 0 | 398 0 | C compiler-rt
16 0 0 0 | 16 0 | C picolibc
0 0 0 2048 | 0 2048 | C stack
24 0 0 0 | 24 0 | device/riscv
22 0 0 0 | 22 0 | machine
20 0 0 0 | 20 0 | main
338 0 0 4 | 338 4 | runtime
16 0 0 0 | 16 0 | runtime/volatile
------------------------------- | --------------- | -------
992 0 0 2052 | 992 2052 | total
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo2162457694/main.bin onto device
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
0
1
1
2
3
5
8
13
21
34
At that point the console output freezes and the red LED starts blinking. So it would appear that both stack and heap overflow will trigger hardware fault, which is the desired behavior.
More recent commit adds the call for the TKey's built-in The following modified package main
import (
"encoding/hex"
"machine"
"time"
)
var (
uart = machine.Serial
)
func main() {
// use default settings for UART
uart.Configure(machine.UARTConfig{})
uart.Write([]byte("Echo console enabled. Type something then press enter:\r\n"))
input := make([]byte, 64)
hash := make([]byte, 32)
i := 0
for {
if uart.Buffered() > 0 {
data, _ := uart.ReadByte()
switch data {
case 13:
// return key
uart.Write([]byte("\r\n"))
uart.Write([]byte("You typed: "))
uart.Write(input[:i])
uart.Write([]byte("\r\n"))
if err := calcHash(input[:i], hash); err != nil {
uart.Write([]byte("Failed to calculate BLAKE2s\r\n"))
i = 0
continue
}
uart.Write([]byte(hex.EncodeToString(hash)))
uart.Write([]byte("\r\n"))
i = 0
default:
// just echo the character
uart.WriteByte(data)
input[i] = data
i++
}
}
time.Sleep(10 * time.Millisecond)
}
}
func calcHash(input []byte, hash []byte) error {
key := []byte("key")
err := machine.BLAKE2s(hash, key, input)
if err != nil {
return err
}
return nil
} Produces the following output: $ tinygo flash -size short -target=tkey examples/echo
code data bss | flash ram
1680 0 2076 | 1680 2076
Auto-detected serial port /dev/ttyACM0
Connecting to device on serial port /dev/ttyACM0 ...
Firmware name0:'tk1 ' name1:'mkdf' version:5
UDI: 00010:8:3:00bc614e
Loading app from /tmp/tinygo2868810019/main.bin onto device
$ tinygo monitor -baudrate=62500
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
Echo console enabled. Type something then press enter:
hello
You typed: hello
f3400892fd799ac07396701cabc0c4aab892dc320645ed106c66b6ae5e681181
what a cool hash
You typed: what a cool hash
e207695eb539abddd8cba0066e6665e022c799e2769dc2d5bf049cfd1426aa29
what a cool hash
You typed: what a cool hash
e207695eb539abddd8cba0066e6665e022c799e2769dc2d5bf049cfd1426aa29 |
I added another commit to implement the runtime |
Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
…such as name and version for TKey Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
…terface Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
…nstruction to halt CPU Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
targets/tkey.ld
Outdated
. = ALIGN(4); | ||
} >RAM | ||
|
||
/* Put the stack at the bottom of RAM, so that the application will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says the stack is at bottom of RAM. But it's above the beginning of .text. If it's growing downwards as usual doesn't it corrupt the loaded device app code?
Indeed.
I think the simplest fix would be to move .stack
to just after .text.init
but before .text
. The .text.init
section is not needed anymore after init and can be freely overwritten.
I didn't realize that the intention was to noisily crash by just happening to try to execute some random data from the stack. I thought you just wanted to have the stack stop growing by stopping at the bottom of RAM.
The comment comes from Cortex-M targets, where we generally place the stack at the bottom of RAM which will generally lead to a crash when reading/writing there.
…cv32 target Signed-off-by: deadprogram <[email protected]>
…on UART Signed-off-by: deadprogram <[email protected]>
Signed-off-by: deadprogram <[email protected]>
…nfig in use for TKey Signed-off-by: deadprogram <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, below mostly just minor nits.
The most important one is ticksToNanoseconds
and nanosecondsToTicks
, which seem to have an incorrect comment.
LGTM with any possible fixes.
Signed-off-by: deadprogram <[email protected]>
Thanks for review and feedback @aykevl @mchack-work now squash/merging. |
This PR is to start adding an implementation for the Tillitis TKey device:
https://tillitis.se/products/tkey/
The only thing working is the
blinky1
example.