├── .gitignore ├── .travis.yml ├── Kconfig ├── LICENSE ├── Makefile ├── README.md ├── TODO.txt ├── apps ├── Kconfig ├── Makefile ├── app.h ├── blinky.c ├── dummy.c ├── echo_console.c ├── fat_mmc_test.c ├── file_loader.c ├── graphics_test.c ├── net_test.c ├── repl.c ├── static_file.c ├── unit_tests.c └── usb_serial_loopback.c ├── boards ├── Kconfig ├── Makefile ├── board.c ├── board.h ├── board_cfg.h ├── burners.mk ├── cc3200_launchxl.board ├── configs │ ├── cc3200_gcc_defconfig │ ├── frdm_kl25z_gcc_defconfig │ ├── lm3s6918_gcc_defconfig │ ├── lm3s6965_gcc_defconfig │ ├── lm4f120xl_gcc_defconfig │ ├── msp430f5529_defconfig │ ├── stm32_hy_24_defconfig │ ├── stm32f3discovery_gcc_defconfig │ ├── stm32f429idiscovery_gcc_defconfig │ ├── stm32f4discovery_gcc_defconfig │ ├── tm4c123g_gcc_defconfig │ ├── tm4c1294_gcc_defconfig │ ├── trinket_pro_defconfig │ ├── unix_sim_gcc_defconfig │ ├── unix_sim_tests_defconfig │ └── unix_sim_unit_tests_defconfig ├── ek_lm3s6965.board ├── ek_lm4f120xl.board ├── ek_tm4c123gxl.board ├── ek_tm4c1294xl.board ├── env │ ├── setenv_frdm_kl25z.sh │ ├── setenv_lm3s6918.sh │ ├── setenv_lm3s6965.sh │ ├── setenv_lm4f120xl.sh │ ├── setenv_msp430f5529.sh │ ├── setenv_stm32_armjishu_28.sh │ ├── setenv_stm32f3discovery.sh │ ├── setenv_stm32f429idiscovery.sh │ ├── setenv_stm32f4discovery.sh │ └── setenv_unix_sim.sh ├── esp8266.board ├── frdm_kl25z.board ├── msp430f5529.board ├── rdk_idm.board ├── stm32_armjishu_28.board ├── stm32_hy_24.board ├── stm32f3discovery.board ├── stm32f429idiscovery.board ├── stm32f4discovery.board ├── trinket_pro.board ├── unix_sim.board └── x86_sim.board ├── doc ├── Makefile ├── _static │ ├── ek_lm3s6965.jpg │ ├── ek_lm4f120xl.jpg │ ├── frdm_kl25z.jpg │ ├── rdk_idm.jpg │ ├── stm32f3discovery.jpg │ └── stm32f4discovery.jpg ├── gen_boards_descs.c ├── gen_chipset_guide.c ├── gen_js_api.c ├── gen_js_api.h ├── manual.txt └── print.h ├── drivers ├── Kconfig ├── Makefile ├── block │ └── block.h ├── gpio │ ├── .js_gpio.c.swm │ ├── .js_gpio.c.swn │ ├── Makefile │ ├── gpio.c │ ├── gpio.h │ ├── gpio.jsapi │ ├── gpio_platform.h │ ├── js_gpio.c │ └── pin.js ├── graphics │ ├── Kconfig │ ├── Makefile │ ├── dogs102x6.c │ ├── dogs102x6.jsapi │ ├── dummy_canvas.c │ ├── dummy_canvas.jsapi │ ├── graphics_screens.h │ ├── ili9320.c │ ├── ili9325.c │ ├── ili9328.c │ ├── ili93xx.c │ ├── ili93xx.jsapi │ ├── ili93xx_bitbang.c │ ├── ili93xx_bitbang.h │ ├── ili93xx_controllers.h │ ├── ili93xx_transport.h │ ├── js_graphics_screens.c │ ├── pcd8544.c │ ├── pcd8544.jsapi │ ├── sdl_screen.c │ ├── sdl_screen.jsapi │ ├── ssd1306.c │ ├── ssd1306.jsapi │ ├── ssd1329.c │ ├── ssd1329.jsapi │ ├── st7735.c │ ├── st7735.jsapi │ ├── st7920.c │ ├── st7920.jsapi │ └── text_lcd.js ├── i2c │ └── i2c.h ├── mmc │ ├── Makefile │ ├── js_mmc.c │ ├── mmc.c │ ├── mmc.h │ └── mmc.jsapi ├── net │ ├── Kconfig │ ├── Makefile │ ├── enc28j60.c │ ├── enc28j60.h │ ├── enc28j60.jsapi │ ├── esp8266.c │ ├── esp8266.h │ ├── esp8266.jsapi │ ├── js_enc28j60.c │ └── js_esp8266.c ├── resources.h ├── serial │ ├── Makefile │ ├── js_serial.c │ ├── js_serial.h │ ├── serial.c │ ├── serial.h │ ├── serial.jsapi │ └── serial_platform.h └── spi │ ├── Makefile │ ├── js_spi.c │ ├── spi.h │ └── spi.jsapi ├── fs ├── Kconfig ├── Makefile ├── builtin_fs │ ├── Makefile │ ├── builtin_fs.c │ └── builtin_fs.h ├── fat │ ├── Makefile │ └── fat.c ├── fs.jsapi ├── js_fs.c ├── local_fs │ ├── Makefile │ └── local_fs.c ├── vfs.c └── vfs.h ├── graphics ├── Makefile ├── canvas.c ├── canvas.h ├── canvas.jsapi ├── chart.c ├── circle.c ├── colors.h ├── font.h ├── graphics.h ├── graphics.jsapi ├── image.c ├── js_canvas.c ├── js_canvas.h ├── js_evaluated_canvas.c ├── js_evaluated_canvas.h ├── js_graphics.c ├── line.c ├── painter.jsapi ├── rect.c └── text.c ├── js ├── Kconfig ├── Makefile ├── _jsapi.h ├── builtins │ ├── Kconfig │ ├── Makefile │ ├── globals.c │ ├── globals.jsapi │ ├── math.c │ ├── math.jsapi │ ├── module.c │ ├── module.jsapi │ ├── timers.c │ └── timers.jsapi ├── class_prototypes │ ├── Makefile │ ├── array_prototype.c │ ├── array_prototype.jsapi │ ├── class_prototypes.jsapi │ ├── function_prototype.c │ ├── function_prototype.jsapi │ ├── object_prototype.c │ ├── object_prototype.jsapi │ ├── string_prototype.c │ ├── string_prototype.jsapi │ ├── typed_array_prototype.c │ └── typed_array_prototype.jsapi ├── js.c ├── js.h ├── js_builtins.c ├── js_builtins.h ├── js_compiler.c ├── js_compiler.h ├── js_emitter.c ├── js_emitter.h ├── js_eval.c ├── js_eval.h ├── js_eval_common.c ├── js_eval_common.h ├── js_event.c ├── js_event.h ├── js_gc.c ├── js_gc.h ├── js_module.c ├── js_module.h ├── js_obj.c ├── js_obj.h ├── js_scan.c ├── js_scan.h ├── js_types.h ├── js_utils.h ├── jsapi_decl.h └── modules │ ├── Kconfig │ ├── Makefile │ ├── assert.js │ ├── max7219.js │ └── thermal_printer.js ├── main ├── Makefile ├── console.c ├── console.h ├── console.jsapi ├── js_console.c ├── main.c ├── tp.h └── version.h ├── mem ├── Kconfig ├── Makefile ├── dlmalloc.c ├── dlmalloc.h ├── mem_cache.c ├── mem_cache.h ├── tmalloc.c └── tmalloc.h ├── net ├── Kconfig ├── Makefile ├── arp.c ├── arp.h ├── dhcpc.c ├── dhcpc.h ├── ether.c ├── ether.h ├── etherif.c ├── etherif.h ├── icmp.c ├── icmp.h ├── ipv4.c ├── ipv4.h ├── js_netif.c ├── js_netif.h ├── net.c ├── net.h ├── net_debug.c ├── net_debug.h ├── net_types.h ├── net_utils.c ├── net_utils.h ├── netif.c ├── netif.h ├── netif.jsapi ├── packet.c ├── packet.h ├── udp.c └── udp.h ├── platform ├── Kconfig ├── Kconfig.toolchain ├── Makefile ├── arm │ ├── Kconfig │ ├── Makefile │ ├── cortex-m.c │ ├── cortex-m.h │ ├── cortex-m.ld.S │ ├── frdm │ │ ├── Kconfig │ │ ├── MKL25Z4.h │ │ ├── Makefile │ │ ├── interrupts.c │ │ ├── kl25z.c │ │ ├── kl25z.chip │ │ ├── kl25z.h │ │ └── kl25z.ld.S │ ├── stm32 │ │ ├── Kconfig │ │ ├── Makefile │ │ ├── stm32.c │ │ ├── stm32.h │ │ ├── stm32_common.h │ │ ├── stm32_conf.h │ │ ├── stm32_entry_gcc.c │ │ ├── stm32_fsmc_lcd.c │ │ ├── stm32_gpio.c │ │ ├── stm32_gpio.h │ │ ├── stm32_i2c.c │ │ ├── stm32_i2c.h │ │ ├── stm32_spi.c │ │ ├── stm32_spi.h │ │ ├── stm32_usart.c │ │ ├── stm32_usart.h │ │ ├── stm32_usb.c │ │ ├── stm32_usb.h │ │ ├── stm32f1xx │ │ │ ├── Makefile │ │ │ ├── interrupts.c │ │ │ ├── stm32f103rbt.chip │ │ │ ├── stm32f103rbt.ld.S │ │ │ ├── stm32f103rct6.ld.S │ │ │ ├── stm32f103rct6.ld.chip │ │ │ ├── stm32f103vet6.chip │ │ │ ├── stm32f103vet6.ld.S │ │ │ ├── stm32f103xx.c │ │ │ ├── stm32f103xx.h │ │ │ ├── stm32f1xx_common.h │ │ │ ├── system_stm32f10x.c │ │ │ └── system_stm32f30x.c │ │ ├── stm32f3xx │ │ │ ├── Makefile │ │ │ ├── interrupts.c │ │ │ ├── stm32f303xx.c │ │ │ ├── stm32f303xx.h │ │ │ ├── stm32f303xx.ld.S │ │ │ ├── stm32f3xx.chip │ │ │ ├── stm32f3xx_common.h │ │ │ └── system_stm32f30x.c │ │ └── stm32f4xx │ │ │ ├── Makefile │ │ │ ├── interrupts.c │ │ │ ├── stm32f407xx.c │ │ │ ├── stm32f407xx.chip │ │ │ ├── stm32f407xx.h │ │ │ ├── stm32f407xx.ld.S │ │ │ ├── stm32f429xx.c │ │ │ ├── stm32f429xx.chip │ │ │ ├── stm32f429xx.h │ │ │ ├── stm32f429xx.ld.S │ │ │ ├── stm32f429xx_interrupts.c │ │ │ ├── stm32f4xx_common.h │ │ │ ├── stm32f4xx_conf.h │ │ │ ├── system_stm32f429xx.c │ │ │ ├── system_stm32f4xx.c │ │ │ └── usb_conf │ │ │ ├── usb_conf.h │ │ │ └── usbd_conf.h │ └── ti │ │ ├── Kconfig │ │ ├── Makefile │ │ ├── cc3200 │ │ ├── Makefile │ │ ├── cc3200.c │ │ ├── cc3200.chip │ │ ├── cc3200.h │ │ ├── cc3200.ld.S │ │ ├── entry_gcc.c │ │ └── interrupts.c │ │ ├── js_stellaris_eth.c │ │ ├── lm3s6918 │ │ ├── Makefile │ │ ├── entry_gcc.c │ │ ├── interrupts.c │ │ ├── lm3s6918.c │ │ ├── lm3s6918.chip │ │ ├── lm3s6918.cmd │ │ ├── lm3s6918.h │ │ └── lm3s6918.ld.S │ │ ├── lm3s6965 │ │ ├── Makefile │ │ ├── entry_gcc.c │ │ ├── interrupts.c │ │ ├── lm3s6965.c │ │ ├── lm3s6965.chip │ │ ├── lm3s6965.cmd │ │ ├── lm3s6965.h │ │ └── lm3s6965.ld.S │ │ ├── lm4f120xl │ │ ├── Makefile │ │ ├── entry_gcc.c │ │ ├── interrupts.c │ │ ├── lm4f120xl.c │ │ ├── lm4f120xl.chip │ │ ├── lm4f120xl.cmd │ │ ├── lm4f120xl.h │ │ └── lm4f120xl.ld.S │ │ ├── stellaris_entry_ccs5.c │ │ ├── stellaris_eth.c │ │ ├── stellaris_eth.h │ │ ├── stellaris_eth.jsapi │ │ ├── ti_arm_mcu.c │ │ ├── ti_arm_mcu.h │ │ ├── ti_arm_mcu_bsp.h │ │ ├── ti_arm_mcu_gpio.c │ │ ├── ti_arm_mcu_i2c.c │ │ ├── ti_arm_mcu_spi.c │ │ ├── ti_arm_mcu_usb.c │ │ ├── tiva_c_emac.c │ │ ├── tiva_c_emac.h │ │ ├── tm4c123g │ │ ├── Makefile │ │ ├── entry_gcc.c │ │ ├── interrupts.c │ │ ├── tm4c123g.c │ │ ├── tm4c123g.chip │ │ ├── tm4c123g.h │ │ └── tm4c123g.ld.S │ │ └── tm4c1294 │ │ ├── Makefile │ │ ├── entry_gcc.c │ │ ├── interrupts.c │ │ ├── tm4c1294.c │ │ ├── tm4c1294.chip │ │ ├── tm4c1294.h │ │ └── tm4c1294.ld.S ├── avr8 │ ├── Kconfig │ ├── Makefile │ ├── atmega328.c │ ├── atmega328.h │ ├── atmega328_i2c.c │ └── atmega328_i2c.h ├── chipset.h ├── esp8266 │ ├── Kconfig │ ├── Makefile │ ├── esp8266.c │ ├── esp8266.h │ ├── esp8266_wifi.c │ ├── esp8266_wifi.h │ ├── esp8266_wifi.jsapi │ ├── js_esp8266_wifi.c │ └── user_config.h ├── msp430 │ ├── Kconfig │ ├── Makefile │ ├── lnk_msp430f5529.cmd │ ├── msp430f5529.c │ ├── msp430f5529.chip │ ├── msp430f5529.h │ ├── msp430f5529_gpio.c │ ├── msp430f5529_gpio.h │ ├── msp430f5529_spi.c │ ├── msp430f5529_usci.c │ └── msp430f5529_usci.h ├── platform.h ├── platform_consts.h ├── ticks.c ├── ticks.h ├── unix │ ├── Kconfig │ ├── Makefile │ ├── js_linux_eth.c │ ├── js_netif_inet.c │ ├── linux_eth.c │ ├── linux_eth.h │ ├── linux_eth.jsapi │ ├── netif_inet.c │ ├── netif_inet.h │ ├── netif_inet.jsapi │ ├── sim.c │ ├── sim.h │ ├── unix.c │ └── unix.h └── x86 │ ├── Kconfig │ ├── Makefile │ ├── boot.s │ ├── vga_term.c │ ├── vga_term.h │ ├── x86.c │ └── x86.ld.S ├── scripts ├── Makefile.config ├── Makefile.toolchain ├── Rules.mk ├── build_dist.sh ├── coveralls.sh ├── defaults.mk ├── footer.mk ├── gcc.mk ├── header.mk ├── kconfig │ ├── .gitignore │ ├── Makefile │ ├── Makefile.orig │ ├── POTFILES.in │ ├── check.sh │ ├── conf.c │ ├── confdata.c │ ├── expr.c │ ├── expr.h │ ├── gconf.c │ ├── gconf.glade │ ├── images.c │ ├── kxgettext.c │ ├── list.h │ ├── lkc.h │ ├── lkc_proto.h │ ├── lxdialog │ │ ├── .gitignore │ │ ├── BIG.FAT.WARNING │ │ ├── check-lxdialog.sh │ │ ├── checklist.c │ │ ├── dialog.h │ │ ├── inputbox.c │ │ ├── menubox.c │ │ ├── textbox.c │ │ ├── util.c │ │ └── yesno.c │ ├── mconf.c │ ├── menu.c │ ├── merge_config.sh │ ├── nconf.c │ ├── nconf.gui.c │ ├── nconf.h │ ├── qconf.cc │ ├── qconf.h │ ├── streamline_config.pl │ ├── symbol.c │ ├── util.c │ ├── zconf.gperf │ ├── zconf.hash.c_shipped │ ├── zconf.l │ ├── zconf.lex.c_shipped │ ├── zconf.tab.c_shipped │ └── zconf.y ├── release_script.sh ├── text_to_c.mk ├── text_to_c_str.sed └── ti_ccs5.mk ├── tests ├── arguments_test.js ├── array_test.js ├── builtins_test.js ├── cast_test.js ├── closure_test.js ├── emit_test.js ├── eval_test.js ├── exp_test.js ├── file_test.js ├── for_test.js ├── fp_test.js ├── func_apply_test.js ├── func_bind_test.js ├── func_constructor_test.js ├── func_test.js ├── gpio_test.js ├── graphics_test.js ├── leak_check.sh ├── math_test.js ├── member_test.js ├── misc_test.js ├── module_test.js ├── netif_test.js ├── object_test.js ├── pong.js ├── properties_test.js ├── prototype_test.js ├── run_tests.sh ├── self_ref.js ├── serial_test.js ├── stack_analyze.sh ├── string_test.js ├── switch_test.js ├── throw_test.js ├── timer_test.js ├── tp_fat_fs.bin ├── typed_array.js └── while_test.js ├── usb ├── Kconfig ├── Makefile ├── cdc_acm.c ├── cdc_acm_descs.c ├── usb_descs.h ├── usbd.h ├── usbd_core.c ├── usbd_core.h └── usbd_core_platform.h └── util ├── Makefile ├── cli.c ├── cli.h ├── debug.c ├── debug.h ├── event.c ├── event.h ├── history.c ├── history.h ├── tnum.c ├── tnum.h ├── tp_misc.h ├── tp_types.h ├── tprintf.c ├── tprintf.h ├── tstr.c ├── tstr.h ├── tstr_list.c └── tstr_list.h /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | build.* 3 | staging.* 4 | .config 5 | .config.old 6 | .sw* 7 | .*.swp 8 | .*.swo 9 | include 10 | */gmon.out 11 | gmon.out 12 | .vagrant 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | before_install: 3 | - sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded 4 | - sudo apt-get update 5 | - sudo apt-get -y install gperf 6 | - sudo apt-get -y install valgrind 7 | - sudo apt-get -y --allow-unauthenticated install gcc-arm-none-eabi 8 | - sudo apt-get -y install gcc-avr 9 | - sudo apt-get -y install avr-libc 10 | - sudo pip install cpp-coveralls 11 | before_script: 12 | - arm-none-eabi-gcc --version 13 | compiler: 14 | - gcc 15 | env: 16 | - DEFCONFIG=unix_sim_tests_defconfig 17 | - DEFCONFIG=unix_sim_unit_tests_defconfig UNIT_TESTS=1 18 | - DEFCONFIG=frdm_kl25z_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 19 | - DEFCONFIG=lm4f120xl_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 20 | - DEFCONFIG=tm4c123g_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 21 | - DEFCONFIG=tm4c1294_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 22 | - DEFCONFIG=cc3200_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 23 | - DEFCONFIG=lm3s6918_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 24 | - DEFCONFIG=lm3s6965_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 25 | - DEFCONFIG=stm32f3discovery_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 26 | - DEFCONFIG=stm32f4discovery_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 27 | - DEFCONFIG=stm32f429idiscovery_gcc_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 28 | - DEFCONFIG=stm32_hy_24_defconfig SKIP_TESTS=1 CROSS_COMPILE=arm-none-eabi- 29 | - DEFCONFIG=trinket_pro_defconfig SKIP_TESTS=1 CROSS_COMPILE=avr- 30 | script: make $DEFCONFIG && make V=1 && cd tests && ./run_tests.sh && ./leak_check.sh && cd .. 31 | after_success: 32 | - ./scripts/coveralls.sh 33 | -------------------------------------------------------------------------------- /Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "TinkerPal Configuration" 2 | 3 | config TINKERPAL 4 | bool 5 | default y 6 | 7 | source "boards/Kconfig" 8 | source "apps/Kconfig" 9 | source "js/Kconfig" 10 | source "net/Kconfig" 11 | source "usb/Kconfig" 12 | 13 | config GRAPHICS 14 | bool "Graphics support" 15 | default y 16 | 17 | source "fs/Kconfig" 18 | source "drivers/Kconfig" 19 | source "platform/Kconfig" 20 | source "mem/Kconfig" 21 | -------------------------------------------------------------------------------- /apps/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Application" 2 | 3 | config CLI 4 | bool 5 | 6 | choice 7 | prompt "Application" 8 | 9 | config APP_REPL 10 | bool "JavaScript Read Eval Print Loop (REPL) Application" 11 | depends on JS 12 | select CLI 13 | 14 | config APP_ECHO_CONSOLE 15 | bool "Echo Command Line Interface (CLI) Application" 16 | select CLI 17 | 18 | config APP_FILE_LOADER 19 | bool "Application accepting a source file via command line" 20 | depends on JS && VFS 21 | 22 | config APP_STATIC_FILE 23 | bool "Static File Application" 24 | depends on JS 25 | 26 | config APP_NET_TEST 27 | bool "Net test" 28 | depends on NET 29 | select CLI 30 | 31 | config APP_GRAPHICS_TEST 32 | bool "Graphics test" 33 | depends on GRAPHICS 34 | select CLI 35 | 36 | config APP_FAT_MMC_TEST 37 | bool "FAT over MMC test" 38 | depends on FAT_FS && MMC 39 | select CLI 40 | 41 | config APP_BLINKY 42 | bool "Blink board LEDs" 43 | depends on GPIO 44 | 45 | config APP_UNIT_TESTS 46 | bool "Unit Tests" 47 | select CLI 48 | 49 | config APP_USB_SERIAL_LOOPBACK 50 | bool "USB Serial Loopback" 51 | depends on USB_DEVICE 52 | 53 | config APP_DUMMY 54 | bool "Dummy. Does nothing. Used for testing" 55 | 56 | endchoice 57 | 58 | config APP_STATIC_FILE_PATH 59 | string "Static File Path" 60 | depends on APP_STATIC_FILE 61 | 62 | config CLI_BUFFER_SIZE 63 | int "CLI Buffer Size" 64 | depends on CLI 65 | default 512 66 | 67 | config CLI_SYNTAX_HIGHLIGHTING 68 | bool "CLI Syntax highlighting" 69 | depends on CLI 70 | default y 71 | 72 | endmenu 73 | -------------------------------------------------------------------------------- /apps/Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(CONFIG_APP_STATIC_FILE),) 2 | 3 | MK_OBJS+=static_file.o 4 | 5 | STATIC_FILE_STR:=$(BUILD)/$(d)/static_file_string.c 6 | STATIC_FILE_PATH=$(shell echo $(CONFIG_APP_STATIC_FILE_PATH) |\ 7 | sed "s/^\([\"']\)\(.*\)\1\$$/\2/g") 8 | 9 | $(eval $(call text_to_c,$(STATIC_FILE_STR),$(STATIC_FILE_PATH),static_file)) 10 | 11 | endif 12 | 13 | MK_OBJS+=$(if $(CONFIG_APP_FILE_LOADER),file_loader.o) 14 | MK_OBJS+=$(if $(CONFIG_APP_REPL),repl.o) 15 | MK_OBJS+=$(if $(CONFIG_APP_UNIT_TESTS),unit_tests.o) 16 | MK_OBJS+=$(if $(CONFIG_APP_ECHO_CONSOLE),echo_console.o) 17 | MK_OBJS+=$(if $(CONFIG_APP_NET_TEST),net_test.o) 18 | MK_OBJS+=$(if $(CONFIG_APP_GRAPHICS_TEST),graphics_test.o) 19 | MK_OBJS+=$(if $(CONFIG_APP_FAT_MMC_TEST),fat_mmc_test.o) 20 | MK_OBJS+=$(if $(CONFIG_APP_BLINKY),blinky.o) 21 | MK_OBJS+=$(if $(CONFIG_APP_USB_SERIAL_LOOPBACK),usb_serial_loopback.o) 22 | MK_OBJS+=$(if $(CONFIG_APP_DUMMY),dummy.o) 23 | -------------------------------------------------------------------------------- /apps/app.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __APP_H__ 26 | #define __APP_H__ 27 | 28 | void app_start(int argc, char *argv[]); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /apps/dummy.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "apps/app.h" 26 | 27 | void app_start(int argc, char *argv[]) 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /boards/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=board.o 2 | 3 | include boards/burners.mk 4 | 5 | ifneq ($(CONFIG_EK_LM4F120XL)$(CONFIG_EK_TM4C123GXL)$(CONFIG_EK_TM4C1294XL),) 6 | BURNER=$(LM4FLASH_BURNER) 7 | BURN_CMD=$(BURNER) $(IMAGE) 8 | endif 9 | 10 | ifneq ($(CONFIG_MSP430F5529_LAUNCHPAD),) 11 | BURNER=$(MSPDEBUG_BURNER) 12 | BURN_CMD=LD_LIBRARY_PATH=$(MSPDEBUG_DIR) $(BURNER) tilib "prog $(TARGET)" 13 | endif 14 | 15 | ifneq ($(CONFIG_STM32F3DISCOVERY)$(CONFIG_STM32F4DISCOVERY)$(CONFIG_STM32F429IDISCOVERY),) 16 | BURNER=$(STLINK_BURNER) 17 | BURN_CMD=$(BURNER) write $(IMAGE) 0x08000000 18 | endif 19 | 20 | ifneq ($(CONFIG_STM32_HY_24),) 21 | PORT?=/dev/ttyUSB1 22 | BURNER=$(STM32LOADER_BURNER) 23 | BURN_NOTE='You can set the port by running PORT= make burn' 24 | BURN_CMD=python $(BURNER) -p $(PORT) -evw $(IMAGE) 25 | endif 26 | 27 | ifneq ($(CONFIG_X86_PLATFORM_EMULATION),) 28 | BURN_CMD=$(X86_BURNER) 29 | endif 30 | 31 | ifneq ($(CONFIG_TRINKET_PRO),) 32 | BURN_CMD=$(ATMEGA328_BURNER) 33 | endif 34 | 35 | # Simulation 36 | ifneq ($(CONFIG_EK_LM3S6965),) 37 | SIMULATE_NOTE='Use CTRL-a-X to exit' 38 | SIMULATE_CMD=qemu-system-arm -s -M lm3s6965evb -nographic -semihosting -no-reboot -net none -kernel $(IMAGE) 39 | endif 40 | 41 | ifneq ($(CONFIG_X86_PLATFORM_EMULATION),) 42 | SIMULATE_CMD=qemu-system-i386 -cdrom $(IMAGE:.bin=.iso) 43 | endif 44 | 45 | ifneq ($(CONFIG_TRINKET_PRO),) 46 | SIMAVR=$(STAGING)/simavr 47 | SIMAVR_FETCHED=$(SIMAVR)/.fetched 48 | AVR_SIMULATOR=$(SIMAVR)/simavr/run_avr 49 | SIMULATOR=$(AVR_SIMULATOR) 50 | SIMULATE_CMD=$(AVR_SIMULATOR) -g -vv -m atmega328p -f 16000000 $(TARGET) 51 | 52 | $(SIMAVR_FETCHED) : 53 | @echo "Fetching simavr" 54 | git clone git://gitorious.org/simavr/simavr.git $(SIMAVR) 55 | @touch $(SIMAVR_FETCHED) 56 | 57 | $(AVR_SIMULATOR) : $(SIMAVR_FETCHED) 58 | @cd $(SIMAVR) && CC=gcc make all && cd - 59 | endif 60 | -------------------------------------------------------------------------------- /boards/cc3200_launchxl.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("CC3200-LAUNCHXL (CC3200 Connected Launchpad)", cc3200, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PB1)) 9 | LED(GPIO_RES(PB2)) 10 | LED(GPIO_RES(PB3)) 11 | 12 | BOARD_END() 13 | -------------------------------------------------------------------------------- /boards/configs/frdm_kl25z_gcc_defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # TinkerPal Configuration 4 | # 5 | CONFIG_TINKERPAL=y 6 | # CONFIG_PLATFORM_EMULATION is not set 7 | # CONFIG_EK_LM4F120XL is not set 8 | # CONFIG_EK_LM3S6965 is not set 9 | # CONFIG_RDK_IDM is not set 10 | # CONFIG_STM32F3DISCOVERY is not set 11 | # CONFIG_STM32F4DISCOVERY is not set 12 | CONFIG_FRDM_KL25Z=y 13 | # CONFIG_MSP430F5529_EXP is not set 14 | # CONFIG_MSP430F5529_LAUNCHPAD is not set 15 | 16 | # 17 | # Platform 18 | # 19 | CONFIG_ARM=y 20 | CONFIG_PLAT_HAS_SERIAL=y 21 | CONFIG_BUFFERED_SERIAL=y 22 | CONFIG_FRDM=y 23 | 24 | # 25 | # Toolchain 26 | # 27 | CONFIG_PLAT_HAS_GCC=y 28 | CONFIG_GCC=y 29 | 30 | # 31 | # Application 32 | # 33 | CONFIG_CLI=y 34 | CONFIG_APP_REPL=y 35 | # CONFIG_APP_ECHO_CONSOLE is not set 36 | # CONFIG_APP_FILE_LOADER is not set 37 | # CONFIG_APP_STATIC_FILE is not set 38 | # CONFIG_APP_GRAPHICS_TEST is not set 39 | # CONFIG_APP_DUMMY is not set 40 | CONFIG_CLI_BUFFER_SIZE=512 41 | CONFIG_CLI_SYNTAX_HIGHLIGHTING=y 42 | 43 | # 44 | # Core Tuning 45 | # 46 | CONFIG_PLAT_HAS_MALLOC=y 47 | CONFIG_MALLOC=y 48 | # CONFIG_DLMALLOC is not set 49 | CONFIG_MEM_CACHE=y 50 | # CONFIG_MEM_PROFILING is not set 51 | CONFIG_JS=y 52 | 53 | # 54 | # JS Tuning 55 | # 56 | CONFIG_MAX_FUNCTION_CALL_ARGS=11 57 | 58 | # 59 | # Built-in Features 60 | # 61 | CONFIG_BUILTIN_GLOBALS=y 62 | CONFIG_BUILTIN_TIMERS=y 63 | CONFIG_BUILTIN_MATH=y 64 | CONFIG_MODULES=y 65 | 66 | # 67 | # Modules 68 | # 69 | CONFIG_MODULE_ASSERT=y 70 | # CONFIG_NET is not set 71 | # CONFIG_GRAPHICS is not set 72 | 73 | # 74 | # Drivers 75 | # 76 | CONFIG_VFS=y 77 | 78 | # 79 | # File Systems 80 | # 81 | CONFIG_BUILTIN_FS=y 82 | CONFIG_BUILTIN_FS_EXTERNAL_PATH="" 83 | # CONFIG_GRAPHICS_SCREENS is not set 84 | -------------------------------------------------------------------------------- /boards/configs/trinket_pro_defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # TinkerPal Configuration 4 | # 5 | CONFIG_TINKERPAL=y 6 | # CONFIG_PLATFORM_EMULATION is not set 7 | # CONFIG_EK_LM4F120XL is not set 8 | # CONFIG_EK_LM3S6965 is not set 9 | # CONFIG_RDK_IDM is not set 10 | # CONFIG_EK_TM4C123GXL is not set 11 | # CONFIG_EK_TM4C1294XL is not set 12 | # CONFIG_CC3200_LAUNCHXL is not set 13 | # CONFIG_STM32F3DISCOVERY is not set 14 | # CONFIG_STM32F4DISCOVERY is not set 15 | # CONFIG_STM32F429IDISCOVERY is not set 16 | # CONFIG_STM32_ARMJISHU_28 is not set 17 | # CONFIG_STM32_HY_24 is not set 18 | # CONFIG_FRDM_KL25Z is not set 19 | # CONFIG_MSP430F5529_EXP is not set 20 | # CONFIG_MSP430F5529_LAUNCHPAD is not set 21 | # CONFIG_X86_PLATFORM_EMULATION is not set 22 | CONFIG_TRINKET_PRO=y 23 | 24 | # 25 | # Application 26 | # 27 | CONFIG_CLI=y 28 | CONFIG_APP_ECHO_CONSOLE=y 29 | # CONFIG_APP_BLINKY is not set 30 | # CONFIG_APP_UNIT_TESTS is not set 31 | # CONFIG_APP_DUMMY is not set 32 | CONFIG_CLI_BUFFER_SIZE=32 33 | CONFIG_CLI_SYNTAX_HIGHLIGHTING=y 34 | # CONFIG_JS is not set 35 | # CONFIG_NET is not set 36 | # CONFIG_GRAPHICS is not set 37 | # CONFIG_VFS is not set 38 | 39 | # 40 | # Drivers 41 | # 42 | CONFIG_GPIO=y 43 | # CONFIG_GRAPHICS_SCREENS is not set 44 | 45 | # 46 | # Platform 47 | # 48 | CONFIG_PLAT_HAS_GPIO=y 49 | CONFIG_PLAT_HAS_SERIAL=y 50 | CONFIG_BUFFERED_SERIAL=y 51 | CONFIG_16_BIT=y 52 | CONFIG_AVR8=y 53 | CONFIG_ATMEGA328=y 54 | CONFIG_PLAT_HAS_GCC=y 55 | CONFIG_GCC=y 56 | # CONFIG_GCC_LTO is not set 57 | # CONFIG_GCC_GCOV is not set 58 | 59 | # 60 | # Memory Allocation Tuning 61 | # 62 | CONFIG_PLAT_HAS_MALLOC=y 63 | CONFIG_MALLOC=y 64 | # CONFIG_DLMALLOC is not set 65 | # CONFIG_MEM_CACHE is not set 66 | # CONFIG_MEM_PROFILING is not set 67 | -------------------------------------------------------------------------------- /boards/configs/unix_sim_unit_tests_defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # TinkerPal Configuration 4 | # 5 | CONFIG_TINKERPAL=y 6 | CONFIG_PLATFORM_EMULATION=y 7 | # CONFIG_EK_LM4F120XL is not set 8 | # CONFIG_EK_LM3S6965 is not set 9 | # CONFIG_RDK_IDM is not set 10 | # CONFIG_EK_TM4C123GXL is not set 11 | # CONFIG_EK_TM4C1294XL is not set 12 | # CONFIG_CC3200_LAUNCHXL is not set 13 | # CONFIG_STM32F3DISCOVERY is not set 14 | # CONFIG_STM32F4DISCOVERY is not set 15 | # CONFIG_STM32F429IDISCOVERY is not set 16 | # CONFIG_STM32_ARMJISHU_28 is not set 17 | # CONFIG_STM32_HY_24 is not set 18 | # CONFIG_FRDM_KL25Z is not set 19 | # CONFIG_MSP430F5529_EXP is not set 20 | # CONFIG_MSP430F5529_LAUNCHPAD is not set 21 | 22 | # 23 | # Application 24 | # 25 | CONFIG_CLI=y 26 | # CONFIG_APP_ECHO_CONSOLE is not set 27 | CONFIG_APP_UNIT_TESTS=y 28 | # CONFIG_APP_DUMMY is not set 29 | CONFIG_CLI_BUFFER_SIZE=512 30 | CONFIG_CLI_SYNTAX_HIGHLIGHTING=y 31 | # CONFIG_JS is not set 32 | CONFIG_NET=y 33 | # CONFIG_GRAPHICS is not set 34 | 35 | # 36 | # Drivers 37 | # 38 | # CONFIG_VFS is not set 39 | # CONFIG_GRAPHICS_SCREENS is not set 40 | 41 | # 42 | # Platform 43 | # 44 | CONFIG_PLAT_HAS_SERIAL=y 45 | CONFIG_UNIX=y 46 | 47 | # 48 | # Platform Emulation Options 49 | # 50 | # CONFIG_PLATFORM_EMULATION_PTY_TERM is not set 51 | # CONFIG_PLATFORM_EMULATION_EXT_TTY is not set 52 | # CONFIG_PLATFORM_EMULATION_BLOCK_DISK is not set 53 | # CONFIG_LINUX_ETH is not set 54 | CONFIG_PLAT_HAS_GCC=y 55 | CONFIG_GCC=y 56 | # CONFIG_GCC_LTO is not set 57 | 58 | # 59 | # Memory Allocation Tuning 60 | # 61 | CONFIG_PLAT_HAS_MALLOC=y 62 | CONFIG_MALLOC=y 63 | # CONFIG_DLMALLOC is not set 64 | CONFIG_MEM_CACHE=y 65 | # CONFIG_MEM_PROFILING is not set 66 | -------------------------------------------------------------------------------- /boards/ek_lm3s6965.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("EK LM3S6965", lm3s6965, ek_lm3s6965) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 8 | MMC_PARAMS(SPI_RES(SSI0), GPIO_RES(PA5), GPIO_RES(PD0)) 9 | 10 | /* SSD1329_PARAMS(_rst, _cs, _cd, _spi_port) */ 11 | SSD1329_PARAMS(GPIO_RES(PC6), GPIO_RES(PA3), GPIO_RES(PC7), SPI_RES(SSI0)) 12 | 13 | BOARD_END() 14 | -------------------------------------------------------------------------------- /boards/ek_lm4f120xl.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("EK LM4F120XL (Stellaris Launchpad)", lm4f120xl, ek_lm4f120xl) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PF1)) 9 | LED(GPIO_RES(PF2)) 10 | LED(GPIO_RES(PF3)) 11 | 12 | /* SSD1306_PARAMS(_i2c_port, _i2c_addr) */ 13 | SSD1306_PARAMS(I2C_RES(I2C1), 0x78) 14 | 15 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 16 | MMC_PARAMS(SPI_RES(SSI0), GPIO_RES(PA5), GPIO_RES(PB6)) 17 | 18 | /* ENC28J60_PARAMS(_spi_port, _cs, _intr) */ 19 | ENC28J60_PARAMS(SPI_RES(SSI1), GPIO_RES(PE3), GPIO_RES(PF4)) 20 | 21 | BOARD_END() 22 | -------------------------------------------------------------------------------- /boards/ek_tm4c123gxl.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("EK TM4C123GXL (Tiva C Launchpad)", tm4c123g, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | /* LED(_gpio) */ 8 | LED(GPIO_RES(PF1)) 9 | LED(GPIO_RES(PF2)) 10 | LED(GPIO_RES(PF3)) 11 | 12 | /* SSD1306_PARAMS(_i2c_port, _i2c_addr) */ 13 | SSD1306_PARAMS(I2C_RES(I2C1), 0x78) 14 | 15 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 16 | MMC_PARAMS(SPI_RES(SSI0), GPIO_RES(PA5), GPIO_RES(PB6)) 17 | 18 | /* ENC28J60_PARAMS(_spi_port, _cs, _intr) */ 19 | ENC28J60_PARAMS(SPI_RES(SSI1), GPIO_RES(PE3), GPIO_RES(PF4)) 20 | 21 | /* ESP8266_PARAMS(_serial_port) */ 22 | ESP8266_PARAMS(UART_RES(UART4)) 23 | 24 | /* PCD8544_PARAMS(_rst, _cs, _cd, _spi_port, _backlight) */ 25 | PCD8544_PARAMS(GPIO_RES(PF3), GPIO_RES(PB6), GPIO_RES(PB4), SPI_RES(SSI0), 26 | GPIO_RES(PF2)) 27 | 28 | /* ST7735_PARAMS(_rst, _cs, _cd, _spi_port, _backlight) */ 29 | ST7735_PARAMS(GPIO_RES(PF3), GPIO_RES(PB6), GPIO_RES(PA6), SPI_RES(SSI0), 30 | GPIO_RES(PF2)) 31 | 32 | /* ST7920_PRARMS(_mode, _rst, _psb, _rs, _rw, _en, d0, d1, d2, d3, d4, d5, d6, d7, _spi_port, _cs) */ 33 | ST7920_PRARMS(ST7920_SERIAL, GPIO_RES(PB1), GPIO_RES(PB0), GPIO_RES(PE3), 34 | GPIO_RES(PA5), GPIO_RES(PA2), GPIO_RES(PF2), GPIO_RES(PD6), GPIO_RES(PE1), 35 | GPIO_RES(PA3), GPIO_RES(PD3), GPIO_RES(PD2), GPIO_RES(PD1), GPIO_RES(PD0), 36 | SPI_RES(SSI0), GPIO_RES(PE3)) 37 | 38 | BOARD_END() 39 | -------------------------------------------------------------------------------- /boards/ek_tm4c1294xl.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("EK TM4C1294XL (Tiva C Connected Launchpad)", tm4c1294, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PF0)) 9 | LED(GPIO_RES(PF4)) 10 | LED(GPIO_RES(PN0)) 11 | LED(GPIO_RES(PN1)) 12 | 13 | /* SSD1306_PARAMS(_i2c_port, _i2c_addr) */ 14 | SSD1306_PARAMS(I2C_RES(I2C1), 0x78) 15 | 16 | BOARD_END() 17 | -------------------------------------------------------------------------------- /boards/env/setenv_frdm_kl25z.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_FRDM_KL25Z != "y" ]] ; then 8 | 9 | echo "Target configuration is not FRDM-KL25Z"; 10 | echo "Please run 'make kl25z_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | fi 19 | -------------------------------------------------------------------------------- /boards/env/setenv_lm3s6918.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_LM3S6918 != "y" ]] ; then 8 | 9 | echo "Target configuration is not LM3S6918"; 10 | echo "Please run 'make lm3s6918_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | elif [[ $CONFIG_TI_CCS5 == "y" ]] ; then 19 | 20 | # Change this to the approproate toolchain location 21 | export TI_CCS5=c:/TI/ccsv5 22 | 23 | fi 24 | -------------------------------------------------------------------------------- /boards/env/setenv_lm3s6965.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_LM3S6965 != "y" ]] ; then 8 | 9 | echo "Target configuration is not LM3S6965"; 10 | echo "Please run 'make lm3s6965_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | elif [[ $CONFIG_TI_CCS5 == "y" ]] ; then 19 | 20 | # Change this to the approproate toolchain location 21 | export TI_CCS5=c:/TI/ccsv5 22 | 23 | fi 24 | -------------------------------------------------------------------------------- /boards/env/setenv_lm4f120xl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_LM4F120XL != "y" ]] ; then 8 | 9 | echo "Target configuration is not LM4F120XL"; 10 | echo "Please run 'make lm4f120xl_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | elif [[ $CONFIG_TI_CCS5 == "y" ]] ; then 19 | 20 | # Change this to the approproate toolchain location 21 | export TI_CCS5=C:/TI/ccsv5 22 | 23 | fi 24 | -------------------------------------------------------------------------------- /boards/env/setenv_msp430f5529.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_MSP430F5529 != "y" ]] ; then 8 | 9 | echo "Target configuration is not MSP430F5529"; 10 | echo "Please run 'make msp430f5529_defconfig'"; 11 | 12 | elif [[ $CONFIG_TI_CCS5 == "y" ]] ; then 13 | 14 | # Change this to the approproate toolchain location 15 | export TI_CCS5=C:/TI/ccsv5 16 | 17 | fi 18 | -------------------------------------------------------------------------------- /boards/env/setenv_stm32_armjishu_28.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_STM32_ARMJISHU_28 != "y" ]] ; then 8 | 9 | echo "Target configuration is not for the CONFIG_STM32_ARMJISHU_28 board"; 10 | echo "Please run 'make stm32_armjishu_28_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | else 19 | 20 | echo "No support for non GCC builds on this platform yet"; 21 | 22 | fi 23 | -------------------------------------------------------------------------------- /boards/env/setenv_stm32f3discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_STM32F3DISCOVERY != "y" ]] ; then 8 | 9 | echo "Target configuration is not STM32F3DISCOVERY"; 10 | echo "Please run 'make stm32f3discovery_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | else 19 | 20 | echo "No support for non GCC builds on this platform yet"; 21 | 22 | fi 23 | -------------------------------------------------------------------------------- /boards/env/setenv_stm32f429idiscovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_STM32F429IDISCOVERY != "y" ]] ; then 8 | 9 | echo "Target configuration is not STM32F429IDISCOVERY"; 10 | echo "Please run 'make stm32f429idiscovery_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | else 19 | 20 | echo "No support for non GCC builds on this platform yet"; 21 | 22 | fi 23 | -------------------------------------------------------------------------------- /boards/env/setenv_stm32f4discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_os=`uname`; 4 | 5 | source build.$host_os/.config 6 | 7 | if [[ $CONFIG_STM32F4DISCOVERY != "y" ]] ; then 8 | 9 | echo "Target configuration is not STM32F4DISCOVERY"; 10 | echo "Please run 'make stm32f4discovery_gcc_defconfig'"; 11 | 12 | elif [[ $CONFIG_GCC == "y" ]] ; then 13 | 14 | TOOLCHAIN_DIR=/usr/local/tinkerpal/sat 15 | 16 | export CROSS_COMPILE=$TOOLCHAIN_DIR/bin/arm-none-eabi- 17 | 18 | else 19 | 20 | echo "No support for non GCC builds on this platform yet"; 21 | 22 | fi 23 | -------------------------------------------------------------------------------- /boards/env/setenv_unix_sim.sh: -------------------------------------------------------------------------------- 1 | unset CROSS_COMPILE 2 | -------------------------------------------------------------------------------- /boards/esp8266.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("ESP8266", NA, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART0)) 6 | 7 | BOARD_END() 8 | -------------------------------------------------------------------------------- /boards/frdm_kl25z.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("Freescale FRDM-KL-25Z", frdm_kl25z, frdm_kl25z) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(0)) 6 | 7 | BOARD_END() 8 | -------------------------------------------------------------------------------- /boards/msp430f5529.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("TI MSP430F5529", msp430f5529, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USCIA1)) 6 | 7 | /* ENC28J60_PARAMS(_spi_port, _cs, _intr) */ 8 | ENC28J60_PARAMS(SPI_RES(USCIA0), GPIO_RES(PC5), GPIO_RES(PA4)) 9 | 10 | /* LED(gpio) */ 11 | LED(GPIO_RES(PA0)) 12 | LED(GPIO_RES(PD7)) 13 | 14 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 15 | MMC_PARAMS(SPI_RES(USCIB1), GPIO_RES(PD1), GPIO_RES(PC7)) 16 | 17 | /* DOGS102X6_PARAMS(_rst, _cs, _cd, _spi_port, _backlight) */ 18 | DOGS102X6_PARAMS(GPIO_RES(PE7), GPIO_RES(PG4), GPIO_RES(PE6), SPI_RES(USCIB1), 19 | GPIO_RES(PG6)) 20 | 21 | BOARD_END() 22 | -------------------------------------------------------------------------------- /boards/rdk_idm.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("RDK-IDM (LM3S6918)", lm3s6918, rdk_idm) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(UART1)) 6 | 7 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 8 | MMC_PARAMS(SPI_RES(SSI1), GPIO_RES(PE3), GPIO_RES(PE1)) 9 | 10 | /* ILI93XX_PARAMS(_rst, _backlight, _trns) */ 11 | ILI93XX_PARAMS(GPIO_RES(PG0), GPIO_RES(PC6), ILI93XX_BITBANG_TRNS({ 12 | .rs = GPIO_RES(PF2), 13 | .wr = GPIO_RES(PF1), 14 | .rd = GPIO_RES(PF0), 15 | .data_port_low = GPIO_RES(GPIO_PORT_B), 16 | .data_port_high = GPIO_RES(GPIO_PORT_A), 17 | })) 18 | 19 | BOARD_END() 20 | -------------------------------------------------------------------------------- /boards/stm32_armjishu_28.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("'ARMJishu' 28'' STM32F103RB based board", stm32f103rbt, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART_PORT1)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PA2)) 9 | LED(GPIO_RES(PA3)) 10 | LED(GPIO_RES(PB2)) 11 | 12 | /* MMC_PARAMS(_spi_port, _mosi, _cs) */ 13 | MMC_PARAMS(SPI_RES(SPI_PORT1), GPIO_RES(PA7), GPIO_RES(PB7)) 14 | 15 | BOARD_END() 16 | -------------------------------------------------------------------------------- /boards/stm32_hy_24.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("HY 24'' STM32F103VET6 based board", stm32f103vet6, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART_PORT2)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PC6)) 9 | LED(GPIO_RES(PC7)) 10 | LED(GPIO_RES(PD13)) 11 | LED(GPIO_RES(PD6)) 12 | 13 | /* LCD daughter board connections: 14 | * 15 | * LEDK:GND | MISO:PA6 16 | * LEDA:5V | SCK:PA5 17 | * NC:PB11 | MOSI:PA7 18 | * RST:PE1 | CS:PD6 19 | * NC:PB10 | NC:PC4 20 | * CS:PD7 | NC:PC5 21 | * DB17:PD10 | DB7:PE10 22 | * DB16:PD9 | DB6:PE9 23 | * DB15:PD8 | DB5:PE8 24 | * DB14:PE15 | DB4:PE7 25 | * DB13:PE14 | DB3:PD1 26 | * DB12:PE13 | DB2:PD0 27 | * DB11:PE12 | DB1:PD15 28 | * DB10:PE11 | DB0:PD14 29 | * RD:PD4 | IRQ:PB6 30 | * RW:PD5 | DOUT:PA6 31 | * RS:PD11 | BUSY:PC13 32 | * NC:PC6 | DIN:PA7 33 | * VCC:3V | CS:PB7 34 | * GND:GND | DCLK:PA5 35 | */ 36 | /* ILI93XX_PARAMS(_rst, _backlight, _trns) */ 37 | ILI93XX_PARAMS(GPIO_RES(PE1), GPIO_RES(PB10), &stm32_fsmc_ili93xx_trns) 38 | 39 | BOARD_END() 40 | -------------------------------------------------------------------------------- /boards/stm32f3discovery.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("STM32F3Discovery", stm32f303xx, stm32f3discovery) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART_PORT2)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PE8)) 9 | LED(GPIO_RES(PE9)) 10 | LED(GPIO_RES(PE10)) 11 | LED(GPIO_RES(PE11)) 12 | LED(GPIO_RES(PE12)) 13 | LED(GPIO_RES(PE13)) 14 | LED(GPIO_RES(PE14)) 15 | LED(GPIO_RES(PE15)) 16 | LED(GPIO_RES(PF1)) 17 | LED(GPIO_RES(PF2)) 18 | LED(GPIO_RES(PF3)) 19 | 20 | /* ILI93XX_PARAMS(_rst, _backlight, _trns) */ 21 | ILI93XX_PARAMS(GPIO_RES(PB1), GPIO_RES(PC0), ILI93XX_BITBANG_TRNS({ 22 | .rs = GPIO_RES(PB15), 23 | .wr = GPIO_RES(PC7), 24 | .rd = GPIO_RES(PC6), 25 | .data_port_low = GPIO_RES(GPIO_PORT_D), 26 | .data_port_high = GPIO_RES(GPIO_PORT_D), 27 | .data_port_high_shift = 8, 28 | })) 29 | 30 | BOARD_END() 31 | -------------------------------------------------------------------------------- /boards/stm32f429idiscovery.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("STM32F429IDiscovery", stm32f429xx, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART_PORT3)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(PG13)) 9 | LED(GPIO_RES(PG14)) 10 | 11 | BOARD_END() 12 | -------------------------------------------------------------------------------- /boards/stm32f4discovery.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("STM32F4Discovery", stm32f407xx, stm32f4discovery) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART_PORT2)) 6 | 7 | /* SSD1306_PARAMS(_i2c_port, _i2c_addr) */ 8 | SSD1306_PARAMS(I2C_RES(I2C_PORT1), 0x78) 9 | 10 | /* ENC28J60_PARAMS(_spi_port, _cs, _intr) */ 11 | ENC28J60_PARAMS(SPI_RES(SPI_PORT1), GPIO_RES(PC5), GPIO_RES(PB1)) 12 | 13 | /* ILI93XX_PARAMS(_rst, _backlight, _trns) */ 14 | ILI93XX_PARAMS(GPIO_RES(PE1), GPIO_RES(PB10), &stm32_fsmc_ili93xx_trns) 15 | 16 | BOARD_END() 17 | -------------------------------------------------------------------------------- /boards/trinket_pro.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, _image) */ 2 | BOARD_START("Trinket Pro", NA, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(USART0)) 6 | 7 | /* LED(gpio) */ 8 | LED(GPIO_RES(_PB5)) 9 | LED(GPIO_RES(_PB6)) 10 | 11 | /* SSD1306_PARAMS(_i2c_port, _i2c_addr) */ 12 | SSD1306_PARAMS(I2C_RES(0), 0x78) 13 | 14 | BOARD_END() 15 | -------------------------------------------------------------------------------- /boards/unix_sim.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, image) */ 2 | BOARD_START("Unix based simulator", NA, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(STDIO_ID)) 6 | 7 | /* SDL_SCREEN_PARAMS(_width, _height) */ 8 | SDL_SCREEN_PARAMS(320, 200) 9 | 10 | BOARD_END() 11 | -------------------------------------------------------------------------------- /boards/x86_sim.board: -------------------------------------------------------------------------------- 1 | /* BOARD_START(_desc, _chipset, image) */ 2 | BOARD_START("X86 based simulator", NA, NA) 3 | 4 | /* DEFAULT_CONSOLE */ 5 | DEFAULT_CONSOLE(UART_RES(0)) 6 | 7 | BOARD_END() 8 | -------------------------------------------------------------------------------- /doc/_static/ek_lm3s6965.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/ek_lm3s6965.jpg -------------------------------------------------------------------------------- /doc/_static/ek_lm4f120xl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/ek_lm4f120xl.jpg -------------------------------------------------------------------------------- /doc/_static/frdm_kl25z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/frdm_kl25z.jpg -------------------------------------------------------------------------------- /doc/_static/rdk_idm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/rdk_idm.jpg -------------------------------------------------------------------------------- /doc/_static/stm32f3discovery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/stm32f3discovery.jpg -------------------------------------------------------------------------------- /doc/_static/stm32f4discovery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/doc/_static/stm32f4discovery.jpg -------------------------------------------------------------------------------- /doc/manual.txt: -------------------------------------------------------------------------------- 1 | TinkerPal User's Manual 2 | ======================= 3 | Eyal Birger 4 | v0.1, May 2013 5 | :toc: 6 | :icons: 7 | :numbered: 8 | :website: http://www.tinkerpal.org 9 | 10 | TinkerPal is a lightweight JavaScript interpreter designed for low cost, low power 11 | microcontrollers (MCUs) allowing rapid prototyping of embedded projects 12 | 13 | Supported Boards 14 | ---------------- 15 | 16 | TI's Stellaris(R) 17 | ~~~~~~~~~~~~~~~~~ 18 | * EK-LM4F120XL (Stellaris(R) LaunchPad) 19 | * EK-LM3S6965 20 | 21 | STMicroelectronics' STM32(C) 22 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 | * STM32F3DISCOVERY 24 | 25 | Quick Start 26 | ----------- 27 | 28 | Downloading TinkerPal 29 | ~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | Flashing TinkerPal 32 | ~~~~~~~~~~~~~~~~~~ 33 | 34 | Connecting via Serial 35 | ~~~~~~~~~~~~~~~~~~~~~ 36 | 37 | Quick Examples 38 | ~~~~~~~~~~~~~~ 39 | 40 | Peripherals Support 41 | ------------------- 42 | 43 | Summary 44 | ~~~~~~~ 45 | 46 | .table 47 | [options="header"] 48 | |================= 49 | ||Stellaris(R) LaunchPad | EK~LM3S6965 | STM32F3DISCOVERY 50 | | GPIO | Supported | Partial | Partial 51 | | UART | Supported | Partial | Partial 52 | |================= 53 | 54 | Hardware Pin Mapping 55 | ~~~~~~~~~~~~~~~~~~~~ 56 | 57 | Hacking TinkerPal 58 | ----------------- 59 | 60 | Development Environment 61 | ~~~~~~~~~~~~~~~~~~~~~~~ 62 | 63 | Porting TinkerPal to a New Board 64 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 65 | 66 | Porting TinkerPal to a New Chipset 67 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | 69 | -------------------------------------------------------------------------------- /drivers/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Drivers" 2 | 3 | config SPI 4 | bool "SPI support" 5 | depends on PLAT_HAS_SPI 6 | default y 7 | 8 | config GPIO 9 | bool "GPIO support" 10 | depends on PLAT_HAS_GPIO 11 | default y 12 | 13 | config MMC 14 | bool "MMC over SPI support" 15 | depends on SPI && GPIO 16 | default y 17 | 18 | config I2C 19 | bool "I2C support" 20 | depends on PLAT_HAS_I2C 21 | default y 22 | 23 | source "drivers/graphics/Kconfig" 24 | 25 | if NET 26 | source "drivers/net/Kconfig" 27 | endif 28 | 29 | endmenu 30 | -------------------------------------------------------------------------------- /drivers/Makefile: -------------------------------------------------------------------------------- 1 | MK_SUBDIRS+=$(if $(CONFIG_ONE_WIRE),one_wire) 2 | MK_SUBDIRS+=$(if $(CONFIG_MMC),mmc) 3 | MK_SUBDIRS+=$(if $(CONFIG_GPIO),gpio) 4 | MK_SUBDIRS+=$(if $(CONFIG_GRAPHICS_SCREENS),graphics) 5 | MK_SUBDIRS+=$(if $(CONFIG_PLAT_HAS_SERIAL),serial) 6 | MK_SUBDIRS+=$(if $(CONFIG_SPI),spi) 7 | MK_SUBDIRS+=$(if $(CONFIG_NET),net) 8 | -------------------------------------------------------------------------------- /drivers/gpio/.js_gpio.c.swm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/drivers/gpio/.js_gpio.c.swm -------------------------------------------------------------------------------- /drivers/gpio/.js_gpio.c.swn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/drivers/gpio/.js_gpio.c.swn -------------------------------------------------------------------------------- /drivers/gpio/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=gpio.o $(if $(CONFIG_JS),js_gpio.o) 2 | MK_JSAPIS=gpio.jsapi 3 | 4 | ifeq ($(CONFIG_JS)$(CONFIG_MODULES),yy) 5 | MK_BUILTIN_FS_INTERNAL_FILES=pin.js 6 | endif 7 | -------------------------------------------------------------------------------- /drivers/gpio/pin.js: -------------------------------------------------------------------------------- 1 | Pin = function(p) { 2 | var self = this; 3 | 4 | self.on = false; 5 | self.pin_num = p; 6 | self.set = function() { digitalWrite(self.pin_num, 1); }; 7 | self.clear = function() { digitalWrite(self.pin_num, 0); }; 8 | self.write = function(v) { digitalWrite(self.pin_num, v); }; 9 | self.read = function() { return digitalRead(self.pin_num); }; 10 | self.toggle = function() { self.on=!self.on; self.write(self.on); }; 11 | self.clear(); 12 | }; 13 | -------------------------------------------------------------------------------- /drivers/graphics/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=$(if $(CONFIG_JS),js_graphics_screens.o) 2 | 3 | ifneq ($(CONFIG_ILI93XX),) 4 | MK_OBJS+=ili93xx.o 5 | MK_JSAPIS+=ili93xx.jsapi 6 | MK_OBJS+=$(if $(CONFIG_ILI93XX_BITBANG),ili93xx_bitbang.o) 7 | MK_OBJS+=$(if $(CONFIG_ILI9328),ili9328.o) 8 | MK_OBJS+=$(if $(CONFIG_ILI9325),ili9325.o) 9 | MK_OBJS+=$(if $(CONFIG_ILI9320),ili9320.o) 10 | endif 11 | 12 | ifneq ($(CONFIG_SDL_SCREEN),) 13 | MK_OBJS+=sdl_screen.o 14 | MK_JSAPIS+=sdl_screen.jsapi 15 | CFLAGS+=$(shell sdl-config --cflags) 16 | LIBS+=$(shell sdl-config --libs) 17 | endif 18 | 19 | ifneq ($(CONFIG_DOGS102X6),) 20 | MK_OBJS+=dogs102x6.o 21 | MK_JSAPIS+=dogs102x6.jsapi 22 | endif 23 | 24 | ifneq ($(CONFIG_SSD1306),) 25 | MK_OBJS+=ssd1306.o 26 | MK_JSAPIS+=ssd1306.jsapi 27 | endif 28 | 29 | ifneq ($(CONFIG_SSD1329),) 30 | MK_OBJS+=ssd1329.o 31 | MK_JSAPIS+=ssd1329.jsapi 32 | endif 33 | 34 | ifneq ($(CONFIG_PCD8544),) 35 | MK_OBJS+=pcd8544.o 36 | MK_JSAPIS+=pcd8544.jsapi 37 | endif 38 | 39 | ifneq ($(CONFIG_ST7735),) 40 | MK_OBJS+=st7735.o 41 | MK_JSAPIS+=st7735.jsapi 42 | endif 43 | 44 | ifneq ($(CONFIG_ST7920),) 45 | MK_OBJS+=st7920.o 46 | MK_JSAPIS+=st7920.jsapi 47 | endif 48 | 49 | ifneq ($(CONFIG_DUMMY_CANVAS),) 50 | MK_OBJS+=dummy_canvas.o 51 | MK_JSAPIS+=dummy_canvas.jsapi 52 | endif 53 | 54 | MODULES=$(if $(CONFIG_TEXT_LCD),text_lcd.js) 55 | MK_BUILTIN_FS_INTERNAL_FILES=$(MODULES) 56 | -------------------------------------------------------------------------------- /drivers/graphics/dogs102x6.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("Dogs102x6", canvas, do_dogs102x6_constructor, { 2 | .params = { 3 | }, 4 | .description = "Dogs102x6 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new Dogs102x6();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/dummy_canvas.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("DummyCanvas", canvas, do_dummy_canvas_constructor, { 2 | .params = { 3 | }, 4 | .description = "Dummy Canvas Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new DummyCanvas();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/ili93xx.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("ILI93XX", canvas, do_ili93xx_constructor, { 2 | .params = { 3 | }, 4 | .description = "ili93xx Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new ILI93XX();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/pcd8544.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("PCD8544", canvas, do_pcd8544_constructor, { 2 | .params = { 3 | }, 4 | .description = "PCD8544 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new PCD8544();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/sdl_screen.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("SDLScreen", canvas, do_sdl_screen_constructor, { 2 | .params = { 3 | }, 4 | .description = "SDL screen Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new SDLScreen();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/ssd1306.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("SSD1306", canvas, do_ssd1306_constructor, { 2 | .params = { 3 | }, 4 | .description = "SSD1306 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new SSD1306();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/ssd1329.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("SSD1329", canvas, do_ssd1329_constructor, { 2 | .params = { 3 | }, 4 | .description = "SSD1329 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new SSD1329();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/st7735.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("ST7735", canvas, do_st7735_constructor, { 2 | .params = { 3 | }, 4 | .description = "ST7735 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new ST7735();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/st7920.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("ST7920", canvas, do_st7920_constructor, { 2 | .params = { 3 | }, 4 | .description = "ST7920 Constructor", 5 | .return_value = "Created object", 6 | .example = "var lcd = new ST7920();\n" 7 | "lcd.pixelDraw(10, 10, 1);", 8 | }) 9 | -------------------------------------------------------------------------------- /drivers/graphics/text_lcd.js: -------------------------------------------------------------------------------- 1 | /* Simple driver for Hitach HD44780 like text LCD screens */ 2 | 3 | TextLCD = function(rs,en,d4,d5,d6,d7) { 4 | this.data = [d7,d6,d5,d4]; 5 | this.rs = rs; 6 | this.en = en; 7 | 8 | digitalWrite(this.en, 0); 9 | 10 | /* Function Set x2: these are special cases instructing a reset 11 | */ 12 | this.cmd(0x33); 13 | /* Function Set x2: 14 | * 1. Special case instructing reset 15 | * 2. Instruct the LCD to move to 4 bit mode 16 | */ 17 | this.cmd(0x32); 18 | /* Function Set: Data length 4 bit 2 lines, 5x7 Font */ 19 | this.cmd(0x28); 20 | /* Display On/Off: Display Off, blinking Off */ 21 | this.cmd(0x08); 22 | /* Clear the screen */ 23 | this.clear(0x01); 24 | /* Entry Mode Set: Enable cursor shift, no autoscroll */ 25 | this.cmd(0x06); 26 | /* Display On/Off: Display On, blinking Off */ 27 | this.cmd(0x0C); 28 | }; 29 | 30 | TextLCD.prototype.xmit = function(d) { 31 | digitalWrite(this.data, d>>4); 32 | digitalPulse(this.en, 1, 0.01); 33 | digitalWrite(this.data, d); 34 | digitalPulse(this.en, 1, 0.01); 35 | }; 36 | 37 | TextLCD.prototype.cmd = function(c) { 38 | digitalWrite(this.rs, 0); 39 | this.xmit(c); 40 | }; 41 | 42 | TextLCD.prototype.clear = function() { this.cmd(0x01); }; 43 | TextLCD.prototype.autoScroll = function() { this.cmd(0x07); }; 44 | TextLCD.prototype.noAutoScroll = function() { this.cmd(0x06); }; 45 | 46 | TextLCD.prototype.print = function(s) { 47 | digitalWrite(this.rs, 1); 48 | for (var i=0;i BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __ESP8266_H__ 26 | #define __ESP8266_H__ 27 | 28 | #include "net/netif.h" 29 | 30 | typedef struct { 31 | resource_t serial_port; 32 | int echo_on; 33 | } esp8266_params_t; 34 | 35 | netif_t *esp8266_new(const esp8266_params_t *params); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /drivers/net/esp8266.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("ESP8266", netif, do_esp8266_constructor, { 2 | .params = { 3 | { .name = "cb", .description = "Callback to be called when device " 4 | "is ready" }, 5 | { .name = "Serial port (optional)", .description = "Serial Port" }, 6 | }, 7 | .description = "ESP8266 Wi-Fi Constructor", 8 | .return_value = "Created object", 9 | .example = "var esp = new ESP8266(function() {\n" 10 | "esp.IPConnect(function() { console.log('connected'); });\n" 11 | "}, UART4);\n" 12 | }) 13 | -------------------------------------------------------------------------------- /drivers/serial/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=serial.o $(if $(CONFIG_JS),js_serial.o) 2 | MK_JSAPIS=serial.jsapi 3 | -------------------------------------------------------------------------------- /drivers/serial/js_serial.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_SERIAL_H__ 26 | #define __JS_SERIAL_H__ 27 | 28 | #include "js/js_obj.h" 29 | 30 | int serial_obj_get_id(obj_t *o); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /drivers/spi/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=$(if $(CONFIG_JS),js_spi.o) 2 | MK_JSAPIS=spi.jsapi 3 | -------------------------------------------------------------------------------- /drivers/spi/spi.jsapi: -------------------------------------------------------------------------------- 1 | PROTOTYPE("SPI", spi, { 2 | }) 3 | 4 | CONSTRUCTOR("SPI", spi, do_spi_constructor, { 5 | .params = { 6 | { .name = "Port ID", .description = "HW SPI Port ID" }, 7 | }, 8 | .description = "SPI Object Constructor", 9 | .return_value = "Created object", 10 | .example = "var s = new SPI(SPI1);\n" 11 | "s.send(0xff);", 12 | }) 13 | 14 | FUNCTION("send", spi, do_spi_send, { 15 | .params = { 16 | { .name = "data" , .description = "Data to be sent on SPI (integer/array)" }, 17 | { .name = "cs" , .description = "Chip select pin (optional)" } 18 | }, 19 | .description = "Sends data via SPI bus", 20 | .return_value = "None", 21 | .example = "var s = new SPI(SPI1);\n" 22 | "s.send(0x1f);", 23 | }) 24 | 25 | FUNCTION("receive", spi, do_spi_receive, { 26 | .params = { 27 | }, 28 | .description = "Reads data via SPI bus (dummy data is sent)", 29 | .return_value = "Integer - value read", 30 | .example = "var s = new SPI(SPI1);\n" 31 | "var data = s.receive();", 32 | }) 33 | -------------------------------------------------------------------------------- /fs/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig VFS 2 | bool "File Systems Support" 3 | default y 4 | 5 | if VFS 6 | 7 | config FAT_FS 8 | bool "FAT support" 9 | depends on PLAT_HAS_BLK || MMC 10 | default y 11 | 12 | config LOCAL_FS 13 | bool "Local file system" 14 | depends on UNIX 15 | default y 16 | help 17 | Local file system access. 18 | Only Unix for now. 19 | 20 | config BUILTIN_FS 21 | bool "Builtin FS" 22 | default y 23 | 24 | config BUILTIN_FS_EXTERNAL_PATH 25 | string "Builtin FS External Files Path" 26 | depends on BUILTIN_FS 27 | 28 | endif 29 | -------------------------------------------------------------------------------- /fs/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=vfs.o $(if $(CONFIG_JS),js_fs.o) 2 | MK_JSAPIS=fs.jsapi 3 | 4 | MK_SUBDIRS+=$(if $(CONFIG_FAT_FS),fat) 5 | MK_SUBDIRS+=$(if $(CONFIG_LOCAL_FS),local_fs) 6 | # Builtin FS must be last since all builtin files must be set 7 | MK_SUBDIRS+=$(if $(CONFIG_BUILTIN_FS),builtin_fs) 8 | -------------------------------------------------------------------------------- /fs/builtin_fs/Makefile: -------------------------------------------------------------------------------- 1 | # $1 source file path 2 | define file_id 3 | $(basename $(notdir $1)) 4 | endef 5 | 6 | # $1 source file path 7 | define file_name 8 | builtin_file_$(call file_id,$1) 9 | endef 10 | 11 | # $1 source file path 12 | define file_str_file 13 | $(BUILD)/$(d)/$(call file_name,$1).c 14 | endef 15 | 16 | # $1 source file path 17 | define file_path 18 | $(shell echo $1 | sed "s/^\([\"']\)\(.*\)\1\$$/\2/g") 19 | endef 20 | 21 | # $1 source file path 22 | define file_desc 23 | { .name = \"$(call file_id,$1)\", .content = &$(call file_name,$1), } 24 | endef 25 | 26 | FILES+=$(BUILTIN_FS_INTERNAL_FILES) 27 | # External files 28 | ifneq ($(CONFIG_BUILTIN_FS_EXTERNAL_PATH),"") 29 | FILES+=$(wildcard $(CONFIG_BUILTIN_FS_EXTERNAL_PATH:"%"=%)/*.*) 30 | endif 31 | 32 | # Convert files into objects 33 | $(foreach f,$(FILES),\ 34 | $(eval $(call text_to_c,$(call file_str_file,$f),$(call file_path,$f),\ 35 | $(call file_name,$f)))) 36 | 37 | # Genrate builtin_fs_files.c 38 | FS_TARGET:=builtin_fs_files.c 39 | FS_FILE:=$(BUILD)/$(d)/$(FS_TARGET) 40 | AUTO_GEN_FILES+=$(FS_FILE) 41 | MK_OBJS+=builtin_fs.o $(FS_TARGET:%.c=%.o) 42 | 43 | $(FS_FILE): $(FILES) $(BUILD)/auto.conf 44 | @echo GEN $@ 45 | $(Q)echo "/* Automatically generated file, DO NOT MANUALLY EDIT */" > $@ 46 | $(Q)echo "#include \"fs/builtin_fs/builtin_fs.h\"" >> $@ 47 | $(Q)$(foreach f,$(FILES),printf "extern char *$(call file_name,$f);\n" >> $@;) 48 | $(Q)echo "const builtin_fs_file_t builtin_fs_files[] = {" >> $@ 49 | $(Q)$(foreach f,$(FILES),printf "$(call file_desc,$f),\n" >> $@;) 50 | $(Q)echo "{}" >> $@ 51 | $(Q)echo "};" >> $@ 52 | -------------------------------------------------------------------------------- /fs/builtin_fs/builtin_fs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __BUILTIN_FS_H__ 26 | #define __BUILTIN_FS_H__ 27 | 28 | #include "util/tstr.h" 29 | 30 | typedef struct { 31 | const char *name; 32 | char **content; 33 | } builtin_fs_file_t; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /fs/fat/Makefile: -------------------------------------------------------------------------------- 1 | MK_LINKS:=$(BSPS_DIR)/FatFS/ff.c 2 | MK_OBJS=fat.o ff.o 3 | ADDITIONAL_INCLUDE_PATHS+=$(BSPS_DIR)/FatFS 4 | -------------------------------------------------------------------------------- /fs/fs.jsapi: -------------------------------------------------------------------------------- 1 | OBJECT("fs", fs, { 2 | .display_name = "File System", 3 | }) 4 | 5 | FUNCTION("readFileSync", fs, do_read_file_sync, { 6 | .params = { 7 | { .name = "path", .description = "File Path" }, 8 | }, 9 | .description = "Synchronously reads the entire contents of a file", 10 | .return_value = "String containing the entire file contents", 11 | .example = "var s = fs.readFileSync('FAT/file.txt');", 12 | }) 13 | 14 | FUNCTION("writeFileSync", fs, do_write_file_sync, { 15 | .params = { 16 | { .name = "path", .description = "File Path" }, 17 | { .name = "data", .description = "String to be written to file" }, 18 | }, 19 | .description = "Synchronously writes the entire contents of a file", 20 | .return_value = "None", 21 | .example = "fs.writeFileSync('FAT/file.txt', 'hello world!');", 22 | }) 23 | 24 | FUNCTION("readdirSync", fs, do_readdir_sync, { 25 | .params = { 26 | { .name = "path", .description = "Directory Path" }, 27 | }, 28 | .description = "Synchronously reads the directory listing of a path", 29 | .return_value = "Array containing the files / directories names", 30 | .example = "var s = fs.readdirSync('FAT/');", 31 | }) 32 | -------------------------------------------------------------------------------- /fs/local_fs/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=local_fs.o 2 | -------------------------------------------------------------------------------- /graphics/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=canvas.o text.o circle.o line.o rect.o image.o chart.o 2 | ifneq ($(CONFIG_JS),) 3 | MK_OBJS+=js_graphics.o js_canvas.o js_evaluated_canvas.o 4 | endif 5 | MK_JSAPIS=graphics.jsapi canvas.jsapi 6 | -------------------------------------------------------------------------------- /graphics/canvas.jsapi: -------------------------------------------------------------------------------- 1 | #include "graphics/painter.jsapi" 2 | 3 | PROTOTYPE("Canvas", canvas, { 4 | }) 5 | 6 | FUNCTION(TpixelDraw, canvas, do_canvas_pixel_draw, { 7 | .params = { 8 | { .name = "x" , .description = "X Coordinate" }, 9 | { .name = "y" , .description = "Y Coordinate" }, 10 | { .name = "value" , .description = "Color Value" } 11 | }, 12 | .description = "Draw a pixel on the screen", 13 | .return_value = "None", 14 | .example = "var l = new ILI93XX();\n" 15 | "l.pixelDraw(10, 10, 1);", 16 | }) 17 | 18 | FUNCTION(Tfill, canvas, do_canvas_fill, { 19 | .params = { 20 | { .name = "value" , .description = "Color Value" } 21 | }, 22 | .description = "Fills the canvas with a color", 23 | .return_value = "None", 24 | .example = "var l = new ILI93XX();\n" 25 | "l.fill(0xfe);", 26 | }) 27 | 28 | FUNCTION(Tflip, canvas, do_canvas_flip, { 29 | .params = { 30 | }, 31 | .description = "Publishes stored buffer onto canvas", 32 | .return_value = "None", 33 | .example = "var l = new SSD1306();\n" 34 | "l.pixelDraw(1, 1, 1);\n" 35 | "l.flip();", 36 | }) 37 | -------------------------------------------------------------------------------- /graphics/js_evaluated_canvas.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_EVALUATED_CANVAS_H__ 26 | #define __JS_EVALUATED_CANVAS_H__ 27 | 28 | #include "js/js_obj.h" 29 | #include "graphics/canvas.h" 30 | 31 | canvas_t *js_evaluated_canvas_new(obj_t *o); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /graphics/painter.jsapi: -------------------------------------------------------------------------------- 1 | #ifndef __PAINTER_DESC__ 2 | #define __PAINTER_DESC__ 3 | 4 | #define TpixelDraw "pixelDraw" 5 | #define Tfill "fill" 6 | #define Tflip "flip" 7 | #define Twidth "width" 8 | #define Theight "height" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /js/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig JS 2 | bool "JS support" 3 | default y 4 | 5 | if JS 6 | 7 | config JS_COMPILER 8 | bool "Run-time Compilation Support (Experimental)" 9 | depends on ARM 10 | default n 11 | 12 | config MAX_FUNCTION_CALL_ARGS 13 | int "Maximum Number of Arguments Allowed on a Function Call" 14 | range 1 20 15 | default 11 16 | help 17 | In general there is no need to tinker with this value. 18 | Change it in case you need to send a large amount of 19 | arguments to a function. 20 | 21 | config OBJ_DOC 22 | bool "Provide object documentation at run time" 23 | default y if UNIX 24 | 25 | source "js/builtins/Kconfig" 26 | source "js/modules/Kconfig" 27 | 28 | endif 29 | -------------------------------------------------------------------------------- /js/Makefile: -------------------------------------------------------------------------------- 1 | MK_SUBDIRS+=class_prototypes builtins $(if $(CONFIG_MODULES),modules) 2 | 3 | MK_OBJS=js.o js_builtins.o js_eval.o js_eval_common.o js_obj.o js_scan.o \ 4 | js_event.o js_emitter.o js_gc.o 5 | MK_OBJS+=$(if $(CONFIG_MODULES),js_module.o) 6 | MK_OBJS+=$(if $(CONFIG_JS_COMPILER),js_compiler.o) 7 | -------------------------------------------------------------------------------- /js/builtins/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Built-in Features" 2 | 3 | config BUILTIN_GLOBALS 4 | bool "Global functions" 5 | default y 6 | 7 | config BUILTIN_TIMERS 8 | bool "Timer functions" 9 | default y 10 | 11 | config BUILTIN_MATH 12 | bool "Math functions" 13 | default y 14 | 15 | endmenu 16 | -------------------------------------------------------------------------------- /js/builtins/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=$(if $(CONFIG_BUILTIN_GLOBALS),globals.o) 2 | MK_OBJS+=$(if $(CONFIG_BUILTIN_TIMERS),timers.o) 3 | MK_OBJS+=$(if $(CONFIG_BUILTIN_MATH),math.o) 4 | MK_OBJS+=$(if $(CONFIG_MODULES),module.o) 5 | MK_JSAPIS:=$(MK_OBJS:%.o=%.jsapi) 6 | -------------------------------------------------------------------------------- /js/builtins/module.jsapi: -------------------------------------------------------------------------------- 1 | /* XXX: this needs a lot more details */ 2 | CATEGORY(module, global_env, { 3 | .display_name = "Module", 4 | }) 5 | 6 | CATEGORY_INIT(modules_init, modules_uninit) 7 | 8 | FUNCTION("require", module, do_require, { 9 | .params = { 10 | { .name = "module_name", .description = "String containing module name to load" }, 11 | }, 12 | .description = "Searches for a module and evaluates its code", 13 | .return_value = "The module's 'exports' property", 14 | .example = "var as = require('assert');", 15 | }) 16 | -------------------------------------------------------------------------------- /js/class_prototypes/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=array_prototype.o string_prototype.o function_prototype.o \ 2 | object_prototype.o typed_array_prototype.o 3 | MK_JSAPIS:=$(MK_OBJS:%.o=%.jsapi) class_prototypes.jsapi 4 | -------------------------------------------------------------------------------- /js/class_prototypes/class_prototypes.jsapi: -------------------------------------------------------------------------------- 1 | CLASS_PROTOTYPE("Number", num_prototype, object_prototype, NUM_CLASS, { 2 | }) 3 | 4 | CLASS_PROTOTYPE("Undefined", undefined_prototype, object_prototype, UNDEFINED_CLASS, { 5 | }) 6 | 7 | CLASS_PROTOTYPE("Null", null_prototype, object_prototype, NULL_CLASS, { 8 | }) 9 | 10 | CLASS_PROTOTYPE("Bool", bool_prototype, object_prototype, BOOL_CLASS, { 11 | }) 12 | -------------------------------------------------------------------------------- /js/js.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_H__ 26 | #define __JS_H__ 27 | 28 | #ifdef CONFIG_JS 29 | 30 | void js_uninit(void); 31 | void js_init(void); 32 | 33 | #else 34 | 35 | static inline void js_uninit(void) { } 36 | static inline void js_init(void) { } 37 | 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /js/js_builtins.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_BUILTINS_H__ 26 | #define __JS_BUILTINS_H__ 27 | 28 | #include "js/js_obj.h" 29 | 30 | void js_builtins_init(void); 31 | void js_builtins_uninit(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /js/js_gc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_GC_H__ 26 | #define __JS_GC_H__ 27 | 28 | void js_gc_run(void); 29 | void __js_gc_run(int sweep_all); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /js/js_module.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_MODULE_H__ 26 | #define __JS_MODULE_H__ 27 | 28 | #include "js/js_obj.h" 29 | #include "util/tstr.h" 30 | 31 | int module_require(obj_t **ret, tstr_t *mod_name); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /js/js_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_TYPES_H__ 26 | #define __JS_TYPES_H__ 27 | 28 | typedef enum { 29 | COMPLETION_NORNAL = 0, 30 | COMPLETION_RETURN = 1, 31 | COMPLETION_CONTINUE = 2, 32 | COMPLETION_BREAK = 3, 33 | COMPLETION_THROW = 4, 34 | } completion_t; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /js/modules/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig MODULES 2 | bool "Modules support" 3 | depends on VFS 4 | default y 5 | 6 | if MODULES 7 | 8 | config MODULE_ASSERT 9 | bool "Assert module" 10 | default y 11 | 12 | config MODULE_THERMAL_PRINTER 13 | bool "Thermal Printer module" 14 | help 15 | Module for a mini thermal printer (e.g. https://learn.adafruit.com/mini-thermal-receipt-printer/) 16 | 17 | config MODULE_MAX7219 18 | bool "MAX7219 8-Digit LED Display Driver" 19 | 20 | endif 21 | -------------------------------------------------------------------------------- /js/modules/Makefile: -------------------------------------------------------------------------------- 1 | # Builtin modules 2 | MODULES+=$(if $(CONFIG_MODULE_ASSERT),assert.js) 3 | MODULES+=$(if $(CONFIG_MODULE_THERMAL_PRINTER),thermal_printer.js) 4 | MODULES+=$(if $(CONFIG_MODULE_MAX7219),max7219.js) 5 | MK_BUILTIN_FS_INTERNAL_FILES=$(MODULES) 6 | -------------------------------------------------------------------------------- /js/modules/max7219.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Eyal Birger, See LICENSE file for details. 2 | * MAX7219 8 Digit LED Display Driver 3 | * 4 | * Connections: VCC, GND, DIN, CLK, CS 5 | * 6 | * Usage: 7 | * var max = require('max7219'); 8 | * var m = new max.instance(new SPI(SPI1), GPIO_PF2); 9 | * m.set("1234HELP"); 10 | * 11 | * Dots are enabled using a bitmap in the second argument, e.g.: 12 | * 13 | * m.set("1234HELP", 0b11); 14 | * 15 | * Will set the two dots under P and L 16 | */ 17 | var mod = module.exports; 18 | 19 | var DECODE_MODE = 0x9; 20 | var INTENSITY = 0xA; 21 | var SCAN_LIMIT = 0xB; 22 | var SHUTDOWN = 0xC; 23 | var DIGIT_MAP = "0123456789-EHLP "; 24 | 25 | mod.instance = function(spi_port, cs) 26 | { 27 | this.spi_port = spi_port; 28 | this.cs = cs; 29 | this.send(INTENSITY, 0xF); 30 | this.send(SCAN_LIMIT, 0x7); 31 | this.send(DECODE_MODE, 0xFF); /* Code B */ 32 | this.send(SHUTDOWN, 0x0); 33 | }; 34 | 35 | mod.instance.prototype.send = function(reg, data) 36 | { 37 | this.spi_port.send([reg, data], this.cs); 38 | }; 39 | 40 | mod.instance.prototype.set = function(str, dot_map) 41 | { 42 | var len = str.length - 1; 43 | var blank = DIGIT_MAP.indexOf(" "); 44 | 45 | if (len > 7) 46 | len = 7; 47 | 48 | for (var i = 0; i < 8; i++) 49 | { 50 | var idx = blank; 51 | 52 | if (i <= len) 53 | { 54 | var cidx = DIGIT_MAP.indexOf(str[len - i]); 55 | 56 | if (cidx != -1) 57 | idx = cidx; 58 | } 59 | if (dot_map && dot_map & (1< BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __TP_H__ 26 | #define __TP_H__ 27 | 28 | void tp_init(void); 29 | void tp_uninit(void); 30 | 31 | /* tp_main calls tp_init */ 32 | int tp_main(int argc, char *argv[]); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /main/version.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __VERSION_H__ 26 | #define __VERSION_H__ 27 | 28 | #include "version_data.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /mem/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Memory Allocation Tuning" 2 | 3 | config PLAT_HAS_MALLOC 4 | bool 5 | 6 | config PLAT_HAS_OWN_MALLOC 7 | bool 8 | 9 | choice 10 | prompt "Memory allocation mode" 11 | default MALLOC 12 | 13 | config MALLOC 14 | bool "Use libc malloc" 15 | depends on PLAT_HAS_MALLOC 16 | 17 | config DLMALLOC 18 | bool "Use Doug Lea malloc" 19 | depends on !TI_CCS5 20 | 21 | config PLAT_MALLOC 22 | bool "Platform Provided Allocation" 23 | depends on PLAT_HAS_OWN_MALLOC 24 | 25 | endchoice 26 | 27 | config MEM_CACHE 28 | bool "Memory cache - pool memory resources" 29 | default y 30 | help 31 | Reduce allocation overhead by grouping similar objects 32 | allocations. 33 | Note: on very small memory platforms (~8KB), the cache overhead 34 | is larger than the allocation overhead. 35 | When not enabled, the mem_cache API reduces to standard allocation 36 | If in doubt, say y 37 | 38 | config MEM_PROFILING 39 | bool "Allow profiling of used memory" 40 | help 41 | In order to profile memory use, additional space is allocated 42 | on each request in order to keep track of allocated memory. 43 | This is used by OBJ_REGISTRY and MEM_ALLOCATION_LIMIT 44 | If in doubt, say n 45 | 46 | config DLMALLOC_STATISTICS 47 | bool "dlmalloc Statistics" 48 | depends on DLMALLOC && MEM_PROFILING 49 | default y if PLATFORM_EMULATION 50 | 51 | config OBJ_REGISTRY 52 | bool "Object Registry Records" 53 | depends on MEM_PROFILING 54 | default y if PLATFORM_EMULATION 55 | 56 | config MEM_ALLOCATION_LIMIT 57 | bool "Limit amount of allocated memory" 58 | depends on MEM_PROFILING 59 | 60 | config MEM_ALLOCATION_LIMIT_BYTES 61 | int "Maximum number of allocated bytes" 62 | depends on MEM_ALLOCATION_LIMIT 63 | default 32768 64 | 65 | endmenu 66 | -------------------------------------------------------------------------------- /mem/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=tmalloc.o $(if $(CONFIG_DLMALLOC),dlmalloc.o) \ 2 | $(if $(CONFIG_MEM_CACHE),mem_cache.o) 3 | -------------------------------------------------------------------------------- /net/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig NET 2 | bool "Networking Support" 3 | default y 4 | 5 | if NET 6 | 7 | config ETHERIF 8 | bool 9 | select ETHERNET 10 | default n 11 | 12 | config PACKET 13 | bool 14 | default n 15 | 16 | config ETHERNET 17 | bool "Ethernet" 18 | select PACKET 19 | depends on ETHERIF 20 | default y 21 | help 22 | Support for Ethernet protocols handling 23 | 24 | config ARP 25 | bool "ARP" 26 | depends on ETHERNET 27 | default y 28 | help 29 | Support for the Address Resolution Protocol (ARP) 30 | 31 | config IPV4 32 | bool "IPv4" 33 | depends on ETHERNET 34 | default y 35 | help 36 | Support for IPv4 37 | 38 | config ICMP 39 | bool "ICMP" 40 | depends on IPV4 41 | default y 42 | help 43 | Support for ICMP 44 | 45 | config UDP 46 | bool "UDP" 47 | depends on IPV4 48 | default y 49 | help 50 | Support for UDP 51 | 52 | config DHCP_CLIENT 53 | bool "DHCP Client" 54 | depends on UDP 55 | default y 56 | help 57 | Support for obtaining an IP address using Dynamic Host 58 | Configuration Protocol (DHCP) 59 | 60 | config NET_DEBUG 61 | bool "Network Debugging" 62 | default y 63 | 64 | endif 65 | -------------------------------------------------------------------------------- /net/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=net.o netif.o net_utils.o 2 | MK_OBJS+=$(if $(CONFIG_JS),js_netif.o) 3 | MK_OBJS+=$(if $(CONFIG_PACKET),packet.o) 4 | MK_OBJS+=$(if $(CONFIG_ETHERIF),etherif.o) 5 | MK_OBJS+=$(if $(CONFIG_ETHERNET),ether.o) 6 | MK_OBJS+=$(if $(CONFIG_ARP),arp.o) 7 | MK_OBJS+=$(if $(CONFIG_IPV4),ipv4.o) 8 | MK_OBJS+=$(if $(CONFIG_ICMP),icmp.o) 9 | MK_OBJS+=$(if $(CONFIG_UDP),udp.o) 10 | MK_OBJS+=$(if $(CONFIG_DHCP_CLIENT),dhcpc.o) 11 | MK_OBJS+=$(if $(CONFIG_NET_DEBUG),net_debug.o) 12 | 13 | MK_JSAPIS=netif.jsapi 14 | -------------------------------------------------------------------------------- /net/dhcpc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __DHCPC_H__ 26 | #define __DHCPC_H__ 27 | 28 | #include "net/etherif.h" 29 | 30 | void dhcpc_stop(etherif_t *ethif); 31 | int dhcpc_start(etherif_t *ethif); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /net/icmp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __ICMP_H__ 26 | #define __ICMP_H__ 27 | 28 | #include "net/etherif.h" 29 | 30 | void icmp_uninit(void); 31 | void icmp_init(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /net/js_netif.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __JS_NETIF_H__ 26 | #define __JS_NETIF_H__ 27 | 28 | #include "js/js_obj.h" 29 | #include "net/netif.h" 30 | 31 | int netif_obj_constructor(netif_t *netif, obj_t **ret, obj_t *this, 32 | int argc, obj_t *argv[]); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /net/net_utils.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __NET_UTILS_H__ 26 | #define __NET_UTILS_H__ 27 | 28 | #include "net/net_types.h" 29 | 30 | u16 net_csum(u16 *addr, u16 byte_len); 31 | /* IPs are in host order */ 32 | u32 ip_addr_parse(char *buf, int len); 33 | char *ip_addr_serialize(u32 ip); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /net/packet.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "net/packet.h" 26 | 27 | static u8 packet_buf[NET_PACKET_SIZE]; 28 | 29 | packet_t g_packet = { 30 | .head = packet_buf, 31 | .ptr = packet_buf, 32 | .tail = packet_buf + sizeof(packet_buf), 33 | .length = sizeof(packet_buf), 34 | }; 35 | -------------------------------------------------------------------------------- /platform/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Platform" 2 | 3 | config PLAT_HAS_GPIO 4 | bool 5 | 6 | config PLAT_HAS_GPIO_INTERRUPTS 7 | bool 8 | 9 | config PLAT_HAS_SERIAL 10 | bool 11 | 12 | config PLAT_HAS_SPI 13 | bool 14 | 15 | config PLAT_HAS_I2C 16 | bool 17 | 18 | config PLAT_HAS_EMBEDDED_ETH 19 | bool 20 | 21 | config PLAT_HAS_PWM 22 | bool 23 | 24 | config BUFFERED_SERIAL 25 | bool 26 | depends on PLAT_HAS_SERIAL 27 | 28 | config PLAT_HAS_BLK 29 | bool 30 | 31 | config PLAT_HAS_USB 32 | bool 33 | 34 | config 16_BIT 35 | bool 36 | 37 | config PLAT_TICKS 38 | bool 39 | 40 | source "platform/arm/Kconfig" 41 | source "platform/msp430/Kconfig" 42 | source "platform/unix/Kconfig" 43 | source "platform/x86/Kconfig" 44 | source "platform/avr8/Kconfig" 45 | source "platform/esp8266/Kconfig" 46 | 47 | source "platform/Kconfig.toolchain" 48 | 49 | endmenu 50 | -------------------------------------------------------------------------------- /platform/Kconfig.toolchain: -------------------------------------------------------------------------------- 1 | config PLAT_HAS_GCC 2 | bool 3 | 4 | config PLAT_HAS_TI_CCS5 5 | bool 6 | 7 | choice 8 | prompt "Toolchain" 9 | default GCC 10 | 11 | config GCC 12 | bool "GCC" 13 | depends on PLAT_HAS_GCC 14 | 15 | config TI_CCS5 16 | bool "TI Code Composer Studio 5" 17 | depends on PLAT_HAS_TI_CCS5 18 | 19 | endchoice 20 | 21 | if GCC 22 | 23 | config GCC_LTO 24 | bool "GCC Link Time Optimization" 25 | 26 | config GCC_GCOV 27 | bool "GCC Coverage Data Generation" 28 | 29 | config GCC_CAST_QUAL 30 | bool "GCC warn on qualifier removal by cast" 31 | 32 | endif 33 | -------------------------------------------------------------------------------- /platform/Makefile: -------------------------------------------------------------------------------- 1 | MK_SUBDIRS+=$(if $(CONFIG_ARM),arm) 2 | MK_SUBDIRS+=$(if $(CONFIG_UNIX),unix) 3 | MK_SUBDIRS+=$(if $(CONFIG_X86),x86) 4 | MK_SUBDIRS+=$(if $(CONFIG_AVR8),avr8) 5 | MK_SUBDIRS+=$(if $(CONFIG_MSP430),msp430) 6 | MK_SUBDIRS+=$(if $(CONFIG_ESP8266),esp8266) 7 | 8 | MK_OBJS+=$(if $(CONFIG_PLAT_TICKS),ticks.o) 9 | -------------------------------------------------------------------------------- /platform/arm/Kconfig: -------------------------------------------------------------------------------- 1 | config ARM 2 | bool 3 | select PLAT_TICKS 4 | 5 | source "platform/arm/ti/Kconfig" 6 | source "platform/arm/stm32/Kconfig" 7 | source "platform/arm/frdm/Kconfig" 8 | -------------------------------------------------------------------------------- /platform/arm/Makefile: -------------------------------------------------------------------------------- 1 | MK_SUBDIRS+=$(if $(CONFIG_TI),ti) 2 | MK_SUBDIRS+=$(if $(CONFIG_STM32),stm32) 3 | MK_SUBDIRS+=$(if $(CONFIG_FRDM),frdm) 4 | 5 | MK_OBJS+=cortex-m.o 6 | -------------------------------------------------------------------------------- /platform/arm/cortex-m.ld.S: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | #define ARM_MEMORY_AREA(name, perm, origin, length) \ 4 | name (perm) : ORIGIN = origin, LENGTH = length 5 | #include "platform/chipset.h" 6 | } 7 | 8 | SECTIONS 9 | { 10 | #ifdef INTERRUPT_SECTION 11 | .interrupts : 12 | { 13 | __vector_table = .; 14 | . = ALIGN(4); 15 | KEEP(*(.isr_vector)) 16 | . = ALIGN(4); 17 | } > INTERRUPTS 18 | #endif 19 | .text : 20 | { 21 | _text = .; 22 | #ifndef INTERRUPT_SECTION 23 | KEEP(*(.isr_vector)) 24 | #endif 25 | *(.text*) 26 | *(.rodata*) 27 | } > FLASH 28 | 29 | .ARM.exidx : 30 | { 31 | __exidx_start = .; 32 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 33 | __exidx_end = .; 34 | } > FLASH 35 | 36 | _etext = .; 37 | 38 | .data : AT(_etext) 39 | { 40 | _data = .; 41 | *(vtable) 42 | *(.data*) 43 | _edata = .; 44 | } > SRAM 45 | 46 | .bss : AT(ADDR(.data) + SIZEOF(.data)) 47 | { 48 | _bss = .; 49 | *(.bss*) 50 | *(COMMON) 51 | _ebss = .; 52 | } > SRAM 53 | 54 | _heap_bottom = .; 55 | 56 | #ifdef STACK_RAM_SECTION 57 | _heap_top = ORIGIN(SRAM) + LENGTH(SRAM); 58 | #else 59 | #define STACK_RAM_SECTION SRAM 60 | _heap_top = ORIGIN(SRAM) + LENGTH(SRAM) - _stack_size; 61 | #endif 62 | 63 | _stack_top = ORIGIN(STACK_RAM_SECTION) + LENGTH(STACK_RAM_SECTION); 64 | } 65 | -------------------------------------------------------------------------------- /platform/arm/frdm/Kconfig: -------------------------------------------------------------------------------- 1 | config FRDM 2 | bool 3 | select ARM 4 | select PLAT_HAS_GCC 5 | select PLAT_HAS_MALLOC 6 | select PLAT_HAS_SERIAL 7 | select BUFFERED_SERIAL 8 | -------------------------------------------------------------------------------- /platform/arm/frdm/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=kl25z.o interrupts.o 2 | 3 | LINKER_SCRIPT:=$(BUILD)/$(d)/kl25z.ld 4 | CFLAGS+=-mcpu=cortex-m0 -O0 -gdwarf-2 -mthumb -fomit-frame-pointer -Wstrict-prototypes -fverbose-asm 5 | LDFLAGS+=-nostartfiles --no-warn-mismatch --entry reset_isr 6 | 7 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 8 | -------------------------------------------------------------------------------- /platform/arm/frdm/kl25z.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(frdm_kl25z) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(INTERRUPTS, rx, 0x00000000, 0xC0) 5 | ARM_MEMORY_AREA(FLASHCFG, rx, 0x00000400, 0x10) 6 | ARM_MEMORY_AREA(FLASH, rx, 0x00000800, 128K - 0x800) 7 | ARM_MEMORY_AREA(SRAM, rwx, 0x1FFFF000, 16K) 8 | 9 | CHIPSET_END() 10 | -------------------------------------------------------------------------------- /platform/arm/frdm/kl25z.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __KL25Z_CONSTS_H__ 26 | #define __KL25Z_CONSTS_H__ 27 | 28 | #define NUM_UARTS 1 /* XXX: temporary */ 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /platform/arm/frdm/kl25z.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/frdm/kl25z.chip" 4 | 5 | #define INTERRUPT_SECTION 6 | 7 | #include "platform/arm/cortex-m.ld.S" 8 | 9 | SECTIONS 10 | { 11 | .cfmprotect : AT(ADDR(.interrupts) + SIZEOF(.interrupts)) 12 | { 13 | . = ALIGN(4); 14 | KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */ 15 | . = ALIGN(4); 16 | } > FLASHCFG 17 | } 18 | -------------------------------------------------------------------------------- /platform/arm/stm32/Kconfig: -------------------------------------------------------------------------------- 1 | config STM32 2 | bool 3 | select ARM 4 | select PLAT_HAS_GCC 5 | select PLAT_HAS_MALLOC 6 | select PLAT_HAS_GPIO 7 | select PLAT_HAS_SERIAL 8 | select PLAT_HAS_SPI 9 | select BUFFERED_SERIAL 10 | select GPIO 11 | 12 | config STM32_USART_NO_IN_AF 13 | bool 14 | 15 | config STM32_GPIO_API_LEGACY 16 | bool 17 | 18 | config STM32_HAS_FSMC_LCD 19 | bool 20 | 21 | config STM32F1XX 22 | bool 23 | select STM32 24 | select STM32_GPIO_API_LEGACY 25 | select STM32_USART_NO_IN_AF 26 | select STM32_HAS_FSMC_LCD 27 | 28 | config STM32F103XX 29 | bool 30 | select STM32F1XX 31 | 32 | config STM32F103RBT 33 | bool 34 | select STM32F103XX 35 | 36 | config STM32F103VET6 37 | bool 38 | select STM32F103XX 39 | 40 | config STM32F103RCT6 41 | bool 42 | select STM32F103XX 43 | 44 | config STM32F3XX 45 | bool 46 | select STM32 47 | 48 | config STM32F303XX 49 | bool 50 | select STM32F3XX 51 | 52 | config STM32F4XX 53 | bool 54 | select STM32 55 | 56 | config STM32F407XX 57 | bool 58 | select STM32F4XX 59 | select STM32_HAS_FSMC_LCD 60 | select PLAT_HAS_I2C 61 | select PLAT_HAS_USB 62 | select USB_DEVICE_QUIRK_SET_ADDR_IMM 63 | 64 | config STM32F429XX 65 | bool 66 | select STM32F4XX 67 | 68 | config STM32_FSMC_LCD 69 | bool "Support for FSMC connected ILI93XX LCD controller" 70 | depends on STM32_HAS_FSMC_LCD 71 | default y 72 | -------------------------------------------------------------------------------- /platform/arm/stm32/Makefile: -------------------------------------------------------------------------------- 1 | STM32_DIR?=$(BSPS_DIR) 2 | MK_SUBDIRS+=$(if $(CONFIG_STM32F1XX),stm32f1xx) 3 | MK_SUBDIRS+=$(if $(CONFIG_STM32F3XX),stm32f3xx) 4 | MK_SUBDIRS+=$(if $(CONFIG_STM32F4XX),stm32f4xx) 5 | 6 | MK_OBJS+=stm32.o stm32_usart.o 7 | MK_OBJS+=$(if $(CONFIG_GPIO),stm32_gpio.o) 8 | MK_OBJS+=$(if $(CONFIG_SPI),stm32_spi.o) 9 | MK_OBJS+=$(if $(CONFIG_I2C),stm32_i2c.o) 10 | MK_OBJS+=$(if $(CONFIG_STM32_FSMC_LCD),stm32_fsmc_lcd.o) 11 | MK_OBJS+=$(if $(CONFIG_USB),stm32_usb.o) 12 | 13 | ifneq ($(CONFIG_GCC),) 14 | ifeq ($(CROSS_COMPILE),) 15 | $(error Please set CROSS_COMPILE environment variable) 16 | endif 17 | MK_OBJS+=stm32_entry_gcc.o 18 | MK_ADDITIONAL_INCLUDES+=stm32_conf.h 19 | endif 20 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __STM32_H__ 26 | #define __STM32_H__ 27 | 28 | int stm32_select(int ms); 29 | unsigned long stm32_get_system_clock(void); 30 | void stm32_msleep(double ms); 31 | void stm32_init(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32_conf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __STM32_CONF_H 26 | #define __STM32_CONF_H 27 | 28 | /* STM32 peripheral lib requires this to be defined */ 29 | #define assert_param(expr) ((void)0) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32_entry_gcc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "platform/arm/cortex-m.h" 26 | #include "main/tp.h" 27 | 28 | void reset_isr(void) 29 | { 30 | extern void SystemInit(void); 31 | 32 | cortex_m_reset_isr(); 33 | SystemInit(); 34 | tp_main(0, (char **)0); 35 | } 36 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/Makefile: -------------------------------------------------------------------------------- 1 | BSP_DIR=$(STM32_DIR)/stm32_f1 2 | BSP_DRIVERS_DIR:=$(BSP_DIR)/Libraries/STM32F10x_StdPeriph_Driver 3 | 4 | INCS:=-I$(BSP_DRIVERS_DIR)/inc \ 5 | -I$(BSP_DIR)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/ \ 6 | -I$(BSP_DIR)/Libraries/CMSIS/CM3/CoreSupport/ 7 | 8 | BSP_SRCS:=stm32f10x_usart.c stm32f10x_rcc.c misc.c 9 | BSP_SRCS+=$(if $(CONFIG_GPIO),stm32f10x_gpio.c) 10 | BSP_SRCS+=$(if $(CONFIG_SPI),stm32f10x_spi.c) 11 | BSP_SRCS+=$(if $(CONFIG_STM32_FSMC_LCD),stm32f10x_fsmc.c) 12 | 13 | MK_OBJS=stm32f103xx.o system_stm32f10x.o interrupts.o $(BSP_SRCS:%.c=%.o) 14 | 15 | MK_LINKS:=$(addprefix $(BSP_DRIVERS_DIR)/src/,$(BSP_SRCS)) 16 | 17 | ifneq ($(CONFIG_GCC),) 18 | ifneq ($(CONFIG_STM32F103RBT),) 19 | LINKER_SCRIPT:=$(BUILD)/$(d)/stm32f103rbt.ld 20 | ST_DEF=STM32F10X_MD 21 | endif 22 | ifneq ($(CONFIG_STM32F103VET6),) 23 | LINKER_SCRIPT:=$(BUILD)/$(d)/stm32f103vet6.ld 24 | ST_DEF=STM32F10X_HD 25 | endif 26 | ifneq ($(CONFIG_STM32F103RCT6),) 27 | LINKER_SCRIPT:=$(BUILD)/$(d)/stm32f103rct6.ld 28 | ST_DEF=STM32F10X_XL 29 | endif 30 | 31 | CFLAGS+=-mthumb -mcpu=cortex-m3 -O3 -mfix-cortex-m3-ldrd -mthumb-interwork \ 32 | -mfloat-abi=soft -ffunction-sections -fdata-sections \ 33 | -fsingle-precision-constant -DSTM32F1 -D$(ST_DEF) $(INCS) -mlittle-endian 34 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 35 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 36 | endif 37 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103rbt.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f103rbt) 2 | 3 | /* MEMORY */ 4 | /* XXX: platform has in fact 48K RAM */ 5 | ARM_MEMORY_AREA(FLASH, rx, 0x08000000, 128K) 6 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 20K) 7 | 8 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 9 | STM32_USART_DEF(1, USART, PA10, PA9, NA, 2) 10 | STM32_USART_DEF(2, USART, PA3, PA2, NA, 1) 11 | STM32_USART_DEF(3, USART, PB11, PB10, NA, 1) 12 | 13 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 14 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_Remap_SPI1) 15 | STM32_SPI_DEF(2, 1, PB13, PB14, PB15, 0) 16 | 17 | CHIPSET_END() 18 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103rbt.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f1xx/stm32f103rbt.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103rct6.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f1xx/stm32f103rct6.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103rct6.ld.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f103rct6) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x08000000, 256K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 48K) 6 | 7 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 8 | STM32_USART_DEF(1, USART, PA10, PA9, NA, 2) 9 | STM32_USART_DEF(2, USART, PA3, PA2, NA, 1) 10 | STM32_USART_DEF(3, USART, PB11, PB10, NA, 1) 11 | 12 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 13 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_Remap_SPI1) 14 | STM32_SPI_DEF(2, 1, PB13, PB14, PB15, 0) 15 | 16 | CHIPSET_END() 17 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103vet6.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f103vet6) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x08000000, 512K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 64K) 6 | 7 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 8 | STM32_USART_DEF(1, USART, PA10, PA9, NA, 2) 9 | STM32_USART_DEF(2, USART, PA3, PA2, NA, 1) 10 | STM32_USART_DEF(3, USART, PB11, PB10, NA, 1) 11 | 12 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 13 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_Remap_SPI1) 14 | STM32_SPI_DEF(2, 1, PB13, PB14, PB15, 0) 15 | 16 | CHIPSET_END() 17 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f1xx/stm32f103vet6.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f1xx/stm32f103vet6.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f3xx/Makefile: -------------------------------------------------------------------------------- 1 | BSP_DIR=$(STM32_DIR)/stm32_f3 2 | BSP_DRIVERS_DIR:=$(BSP_DIR)/Libraries/STM32F30x_StdPeriph_Driver 3 | 4 | INCS:=-I$(BSP_DRIVERS_DIR)/inc \ 5 | -I$(BSP_DIR)/Libraries/CMSIS/Device/ST/STM32F30x/Include \ 6 | -I$(BSP_DIR)/Libraries/CMSIS/Include 7 | 8 | BSP_SRCS:=stm32f30x_usart.c stm32f30x_rcc.c stm32f30x_misc.c 9 | BSP_SRCS+=$(if $(CONFIG_GPIO),stm32f30x_gpio.c) 10 | BSP_SRCS+=$(if $(CONFIG_SPI),stm32f30x_spi.c) 11 | 12 | MK_LINKS:=$(addprefix $(BSP_DRIVERS_DIR)/src/,$(BSP_SRCS)) 13 | 14 | MK_OBJS=stm32f303xx.o system_stm32f30x.o interrupts.o $(BSP_SRCS:%.c=%.o) 15 | 16 | ifneq ($(CONFIG_GCC),) 17 | LINKER_SCRIPT:=$(BUILD)/$(d)/stm32f303xx.ld 18 | 19 | CFLAGS+=-mthumb -march=armv7e-m -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -O3 \ 20 | -ffunction-sections -fdata-sections -fsingle-precision-constant \ 21 | -DSTM32F3 $(INCS) -mlittle-endian 22 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 23 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 24 | endif 25 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f3xx/stm32f303xx.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f3xx/stm32f3xx.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f3xx/stm32f3xx.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f303xx) 2 | 3 | /* MEMORY */ 4 | /* XXX: platform has in fact 48K RAM */ 5 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 256K) 6 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 40K) 7 | 8 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 9 | STM32_USART_DEF(1, USART, PB7, PB6, GPIO_AF_7, 2) 10 | STM32_USART_DEF(2, USART, PA3, PA2, GPIO_AF_7, 1) 11 | STM32_USART_DEF(3, USART, PB11, PB10, GPIO_AF_7, 1) 12 | STM32_USART_DEF(4, UART, PB11, PB10, GPIO_AF_5, 1) 13 | STM32_USART_DEF(5, UART, PD2, PC12, GPIO_AF_5, 1) 14 | 15 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 16 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_AF_5) 17 | STM32_SPI_DEF(2, 1, PB13, PB14, PB15, GPIO_AF_5) 18 | STM32_SPI_DEF(3, 1, PC10, PC11, PC12, GPIO_AF_6) 19 | 20 | CHIPSET_END() 21 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f4xx/stm32f407xx.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f407xx) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x08000000, 1024K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 128K) 6 | ARM_MEMORY_AREA(CCM, rwx, 0x10000000, 64K) 7 | 8 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 9 | STM32_USART_DEF(1, USART, PA10, PA9, GPIO_AF_USART1, 2) 10 | STM32_USART_DEF(2, USART, PA3, PA2, GPIO_AF_USART2, 1) 11 | STM32_USART_DEF(3, USART, PB11, PB10, GPIO_AF_USART3, 1) 12 | STM32_USART_DEF(4, UART, PA1, PA0, GPIO_AF_UART4, 1) 13 | STM32_USART_DEF(5, UART, PD2, PC12, GPIO_AF_UART5, 1) 14 | STM32_USART_DEF(6, USART, PC7, PC6, GPIO_AF_USART6, 2) 15 | 16 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 17 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_AF_SPI1) 18 | STM32_SPI_DEF(2, 1, PB10, PC2, PC3, GPIO_AF_SPI2) 19 | STM32_SPI_DEF(3, 1, PC10, PC11, PC12, GPIO_AF_SPI3) 20 | 21 | /* I2C (num, apb, sclpin, sdapin) */ 22 | STM32_I2C_DEF(1, 1, PB8, PB9) 23 | STM32_I2C_DEF(2, 1, PB10, PB11) 24 | STM32_I2C_DEF(3, 1, PA8, PC9) 25 | 26 | CHIPSET_END() 27 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f4xx/stm32f407xx.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f4xx/stm32f407xx.chip" 4 | 5 | #define STACK_RAM_SECTION CCM 6 | 7 | #include "platform/arm/cortex-m.ld.S" 8 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f4xx/stm32f429xx.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(stm32f429xx) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x08000000, 2048K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 192K) 6 | ARM_MEMORY_AREA(CCM, rwx, 0x10000000, 64K) 7 | 8 | /* USART (num, type, rxpin, txpin, afsig, apb) */ 9 | STM32_USART_DEF(1, USART, PA10, PA9, GPIO_AF_USART1, 2) 10 | STM32_USART_DEF(2, USART, PA3, PA2, GPIO_AF_USART2, 1) 11 | STM32_USART_DEF(3, USART, PB11, PB10, GPIO_AF_USART3, 1) 12 | STM32_USART_DEF(4, UART, PA1, PA0, GPIO_AF_UART4, 1) 13 | STM32_USART_DEF(5, UART, PD2, PC12, GPIO_AF_UART5, 1) 14 | STM32_USART_DEF(6, USART, PC7, PC6, GPIO_AF_USART6, 2) 15 | STM32_USART_DEF(7, UART, PE7, PE9, GPIO_AF_UART7, 1) 16 | STM32_USART_DEF(8, UART, PE0, PE1, GPIO_AF_UART8, 1) 17 | 18 | /* SPI (num, apb, clkpin, misopin, mosipin, afsig) */ 19 | STM32_SPI_DEF(1, 2, PA5, PA6, PA7, GPIO_AF_SPI1) 20 | STM32_SPI_DEF(2, 1, PB10, PC2, PC3, GPIO_AF_SPI2) 21 | STM32_SPI_DEF(3, 1, PC10, PC11, PC12, GPIO_AF_SPI3) 22 | STM32_SPI_DEF(4, 2, PE2, PE5, PE6, GPIO_AF_SPI4) 23 | STM32_SPI_DEF(5, 2, PF7, PF8, PF9, GPIO_AF_SPI5) 24 | STM32_SPI_DEF(6, 2, PG13, PG12, PG14, GPIO_AF_SPI6) 25 | 26 | CHIPSET_END() 27 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f4xx/stm32f429xx.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/stm32/stm32f4xx/stm32f429xx.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/stm32/stm32f4xx/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file IO_Toggle/stm32f4xx_conf.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 19-September-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_CONF_H 24 | #define __STM32F4xx_CONF_H 25 | 26 | #if defined (HSE_VALUE) && defined (CONFIG_STM32F4DISCOVERY) 27 | /* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ 28 | #undef HSE_VALUE 29 | #define HSE_VALUE ((uint32_t)8000000) 30 | #endif /* HSE_VALUE */ 31 | 32 | #endif /* __STM32F4xx_CONF_H */ 33 | 34 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 35 | -------------------------------------------------------------------------------- /platform/arm/ti/Kconfig: -------------------------------------------------------------------------------- 1 | config TI 2 | bool 3 | 4 | config STELLARIS 5 | bool 6 | select ARM 7 | select TI 8 | select PLAT_HAS_GCC 9 | select PLAT_HAS_TI_CCS5 10 | select PLAT_HAS_GPIO 11 | select PLAT_HAS_SERIAL 12 | select BUFFERED_SERIAL 13 | select PLAT_HAS_SPI 14 | select PLAT_HAS_MALLOC 15 | 16 | config TIVA_C 17 | bool 18 | select ARM 19 | select TI 20 | select PLAT_HAS_GCC 21 | select PLAT_HAS_GPIO 22 | select PLAT_HAS_SERIAL 23 | select BUFFERED_SERIAL 24 | select PLAT_HAS_SPI 25 | select PLAT_HAS_MALLOC 26 | 27 | config CC3200 28 | bool 29 | select ARM 30 | select TI 31 | select PLAT_HAS_GCC 32 | select PLAT_HAS_GPIO 33 | select PLAT_HAS_SERIAL 34 | select BUFFERED_SERIAL 35 | select PLAT_HAS_MALLOC 36 | 37 | config STELLARIS_ETH 38 | bool 39 | depends on STELLARIS && PLAT_HAS_EMBEDDED_ETH && NET 40 | select ETHERIF 41 | default y 42 | 43 | config TIVA_C_EMAC 44 | bool 45 | depends on TIVA_C && PLAT_HAS_EMBEDDED_ETH && NET 46 | select ETHERIF 47 | default y 48 | 49 | config TI_I2C_WAIT_FOR_BUSY_WAR 50 | bool 51 | 52 | config LM3S6918 53 | bool 54 | select STELLARIS 55 | select PLAT_HAS_EMBEDDED_ETH 56 | 57 | config LM3S6965 58 | bool 59 | select STELLARIS 60 | select PLAT_HAS_PWM 61 | select PLAT_HAS_EMBEDDED_ETH 62 | 63 | config LM4F120XL 64 | bool 65 | select STELLARIS 66 | select PLAT_HAS_GPIO_INTERRUPTS 67 | select PLAT_HAS_I2C 68 | select PLAT_HAS_USB 69 | 70 | config TM4C123G 71 | bool 72 | select TIVA_C 73 | select PLAT_HAS_I2C 74 | select PLAT_HAS_GPIO_INTERRUPTS 75 | select PLAT_HAS_PWM 76 | select PLAT_HAS_USB 77 | 78 | config TM4C1294 79 | bool 80 | select TIVA_C 81 | select PLAT_HAS_PWM 82 | select PLAT_HAS_EMBEDDED_ETH 83 | select PLAT_HAS_I2C 84 | select PLAT_HAS_USB 85 | select TI_I2C_WAIT_FOR_BUSY_WAR 86 | -------------------------------------------------------------------------------- /platform/arm/ti/Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(CONFIG_STELLARIS),) 2 | TI_ARM_MCU_BSP_DIR=$(BSPS_DIR)/stellarisware 3 | endif 4 | ifneq ($(CONFIG_TIVA_C),) 5 | TI_ARM_MCU_BSP_DIR=$(BSPS_DIR)/tivaware 6 | endif 7 | ifneq ($(CONFIG_CC3200),) 8 | TI_ARM_MCU_BSP_DIR=$(BSPS_DIR)/cc3200-sdk 9 | endif 10 | 11 | ADDITIONAL_INCLUDES:=$(ADDITIONAL_INCLUDES) $(d)/ti_arm_mcu_bsp.h 12 | MK_OBJS=ti_arm_mcu.o 13 | MK_OBJS+=$(if $(CONFIG_TI_CCS5),stellaris_entry_ccs5.o) 14 | MK_OBJS+=$(if $(CONFIG_GPIO),ti_arm_mcu_gpio.o) 15 | MK_OBJS+=$(if $(CONFIG_SPI),ti_arm_mcu_spi.o) 16 | MK_OBJS+=$(if $(CONFIG_I2C),ti_arm_mcu_i2c.o) 17 | MK_OBJS+=$(if $(CONFIG_USB),ti_arm_mcu_usb.o) 18 | ifneq ($(CONFIG_STELLARIS_ETH),) 19 | MK_OBJS+=stellaris_eth.o $(if $(CONFIG_JS),js_stellaris_eth.o) 20 | MK_JSAPIS+=stellaris_eth.jsapi 21 | endif 22 | MK_OBJS+=$(if $(CONFIG_TIVA_C_EMAC),tiva_c_emac.o) 23 | 24 | MK_SUBDIRS+=$(if $(CONFIG_LM4F120XL),lm4f120xl) 25 | MK_SUBDIRS+=$(if $(CONFIG_LM3S6965),lm3s6965) 26 | MK_SUBDIRS+=$(if $(CONFIG_LM3S6918),lm3s6918) 27 | MK_SUBDIRS+=$(if $(CONFIG_TM4C123G),tm4c123g) 28 | MK_SUBDIRS+=$(if $(CONFIG_TM4C1294),tm4c1294) 29 | MK_SUBDIRS+=$(if $(CONFIG_CC3200),cc3200) 30 | 31 | ifneq ($(CONFIG_TI_CCS5),) 32 | TI_COMPILER:=$(TI_CCS5)/tools/compiler/tms470_4.9.5 33 | CC=$(TI_COMPILER)/bin/cl470 34 | TI_OBJ2BIN_PATH:=$(TI_CCS5)/utils/tiobj2bin 35 | OBJ2BIN=$(shell cygpath -u "$(TI_OBJ2BIN_PATH)/tiobj2bin.bat") 36 | 37 | gen_image=$(OBJ2BIN) $< $(IMAGE) "$(TI_COMPILER)/bin/ofd470" \ 38 | "$(TI_COMPILER)/bin/hex470" "$(TI_OBJ2BIN_PATH)/mkhex4bin" 39 | CFLAGS+=--abi=eabi -me --ual --include_path=$(TI_ARM_MCU_BSP_DIR) 40 | LDFLAGS+=--abi=eabi -me --ual 41 | LIBS+=-l"libc.a" 42 | endif 43 | 44 | ifneq ($(CONFIG_GCC),) 45 | ifeq ($(CROSS_COMPILE),) 46 | $(error Please set CROSS_COMPILE environment variable) 47 | endif 48 | endif 49 | -------------------------------------------------------------------------------- /platform/arm/ti/cc3200/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=cc3200.o interrupts.o 2 | 3 | ifneq ($(CONFIG_GCC),) 4 | BSP_SRCS:=systick.c gpio.c interrupt.c uart.c pin.c cpu.c prcm.c 5 | 6 | MK_LINKS:=$(addprefix $(TI_ARM_MCU_BSP_DIR)/driverlib/,$(BSP_SRCS)) 7 | MK_OBJS+=entry_gcc.o $(BSP_SRCS:%.c=%.o) 8 | 9 | CFLAGS_$(BUILD)/$d/prcm.o+=-Wno-unused-variable 10 | CFLAGS+=-I$(TI_ARM_MCU_BSP_DIR)/driverlib 11 | 12 | LINKER_SCRIPT:=$(BUILD)/$(d)/cc3200.ld 13 | CFLAGS+=-mthumb -mcpu=cortex-m4 -O3 -ffunction-sections -fdata-sections \ 14 | -I$(TI_ARM_MCU_BSP_DIR) -Dgcc -fsingle-precision-constant 15 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 16 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 17 | endif 18 | -------------------------------------------------------------------------------- /platform/arm/ti/cc3200/cc3200.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(cc3200) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(SRAM, rwx, 0x20004000, 192K) 5 | 6 | CHIPSET_END() 7 | -------------------------------------------------------------------------------- /platform/arm/ti/cc3200/cc3200.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/cc3200/cc3200.chip" 4 | 5 | /* No Flash for now */ 6 | #define FLASH SRAM 7 | 8 | #include "platform/arm/cortex-m.ld.S" 9 | -------------------------------------------------------------------------------- /platform/arm/ti/cc3200/entry_gcc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "inc/hw_nvic.h" 26 | #include "inc/hw_types.h" 27 | #include "platform/arm/cortex-m.h" 28 | #include "main/tp.h" 29 | 30 | void reset_isr(void) 31 | { 32 | cortex_m_reset_isr(); 33 | 34 | tp_main(0, (char **)0); 35 | } 36 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6918/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=lm3s6918.o interrupts.o 2 | 3 | ifneq ($(CONFIG_TI_CCS5),) 4 | CFLAGS+=-mv7M3 --code_state=16 --define=PART_LM3S6918 5 | LDFLAGS+=-mv7M3 6 | LINKER_SCRIPT:=$(d)/lm3s6918.cmd 7 | # Currently require pre-compiled version of driverlib for ccs5 8 | LIBS+=-l"$(TI_ARM_MCU_BSP_DIR)/driverlib/ccs-cm3/Debug/driverlib-cm3.lib" 9 | endif 10 | 11 | ifneq ($(CONFIG_GCC),) 12 | BSP_SRCS:=systick.c sysctl.c gpio.c interrupt.c uart.c ssi.c cpu.c pwm.c \ 13 | $(if $(CONFIG_STELLARIS_ETH),ethernet.c) 14 | 15 | MK_LINKS:=$(addprefix $(TI_ARM_MCU_BSP_DIR)/driverlib/,$(BSP_SRCS)) 16 | 17 | MK_OBJS+=entry_gcc.o $(BSP_SRCS:%.c=%.o) 18 | 19 | LINKER_SCRIPT:=$(BUILD)/$(d)/lm3s6918.ld 20 | CFLAGS+=-mthumb -mcpu=cortex-m3 -O3 \ 21 | -ffunction-sections -fdata-sections -DPART_LM3S6918 \ 22 | -I$(TI_ARM_MCU_BSP_DIR) -Dgcc -fsingle-precision-constant 23 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 24 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 25 | endif 26 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6918/entry_gcc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "inc/hw_nvic.h" 26 | #include "inc/hw_types.h" 27 | #include "platform/arm/cortex-m.h" 28 | #include "main/tp.h" 29 | 30 | void reset_isr(void) 31 | { 32 | cortex_m_reset_isr(); 33 | 34 | tp_main(0, (char **)0); 35 | } 36 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6918/lm3s6918.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(lm3s6918) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 256K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 64K) 6 | 7 | /* UART (num, rx, tx) */ 8 | TI_UART_DEF(0, PA0, PA1) 9 | TI_UART_DEF(1, PD2, PD3) 10 | 11 | /* SSI (num, clkpin, fsspin, rxpin, txpin) */ 12 | TI_SSI_DEF(0, PA2, PA3, PA4, PA5) 13 | TI_SSI_DEF(1, PE0, PE1, PE2, PE3) 14 | 15 | CHIPSET_END() 16 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6918/lm3s6918.cmd: -------------------------------------------------------------------------------- 1 | --retain=g_pfnVectors 2 | 3 | #include "autoconf.h" 4 | 5 | --heap_size=20480 6 | --stack_size=4096 7 | 8 | #define APP_BASE 0x00000000 9 | #define RAM_BASE 0x20000000 10 | 11 | /* System memory map */ 12 | 13 | MEMORY 14 | { 15 | /* Application stored in and executes from internal flash */ 16 | FLASH (RX) : origin = APP_BASE, length = 0x00040000 17 | /* Application uses internal RAM for data */ 18 | SRAM (RWX) : origin = 0x20000000, length = 0x00008000 19 | } 20 | 21 | /* Section allocation in memory */ 22 | 23 | SECTIONS 24 | { 25 | .intvecs: > APP_BASE 26 | .text : > FLASH 27 | .const : > FLASH 28 | .cinit : > FLASH 29 | .pinit : > FLASH 30 | .init_array : > FLASH 31 | 32 | .vtable : > RAM_BASE 33 | .data : > SRAM 34 | .bss : > SRAM 35 | .sysmem : > SRAM 36 | .stack : > SRAM 37 | } 38 | 39 | _stack_top = __stack + 512; 40 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6918/lm3s6918.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/lm3s6918/lm3s6918.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6965/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=lm3s6965.o interrupts.o 2 | 3 | ifneq ($(CONFIG_TI_CCS5),) 4 | CFLAGS+=-mv7M3 --code_state=16 --define=PART_LM3S6965 5 | LDFLAGS+=-mv7M3 6 | LINKER_SCRIPT:=$(d)/lm3s6965.cmd 7 | # Currently require pre-compiled version of driverlib for ccs5 8 | LIBS+=-l"$(TI_ARM_MCU_BSP_DIR)/driverlib/ccs-cm3/Debug/driverlib-cm3.lib" 9 | endif 10 | 11 | ifneq ($(CONFIG_GCC),) 12 | BSP_SRCS:=systick.c sysctl.c gpio.c interrupt.c uart.c ssi.c cpu.c pwm.c \ 13 | $(if $(CONFIG_STELLARIS_ETH),ethernet.c) 14 | 15 | MK_LINKS:=$(addprefix $(TI_ARM_MCU_BSP_DIR)/driverlib/,$(BSP_SRCS)) 16 | 17 | MK_OBJS+=entry_gcc.o $(BSP_SRCS:%.c=%.o) 18 | 19 | LINKER_SCRIPT:=$(BUILD)/$(d)/lm3s6965.ld 20 | CFLAGS+=-mthumb -mcpu=cortex-m3 -O3 \ 21 | -ffunction-sections -fdata-sections -DPART_LM3S6965 \ 22 | -I$(TI_ARM_MCU_BSP_DIR) -Dgcc -fsingle-precision-constant 23 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 24 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 25 | endif 26 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6965/entry_gcc.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #include "inc/hw_nvic.h" 26 | #include "inc/hw_types.h" 27 | #include "platform/arm/cortex-m.h" 28 | #include "main/tp.h" 29 | 30 | void reset_isr(void) 31 | { 32 | cortex_m_reset_isr(); 33 | 34 | tp_main(0, (char **)0); 35 | } 36 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6965/lm3s6965.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(lm3s6965) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 256K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 64K) 6 | 7 | /* UART (num, rx, tx) */ 8 | TI_UART_DEF(0, PA0, PA1) 9 | 10 | /* SSI (num, clkpin, fsspin, rxpin, txpin) */ 11 | TI_SSI_DEF(0, PA2, PA2, PA4, PA5) 12 | 13 | CHIPSET_END() 14 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6965/lm3s6965.cmd: -------------------------------------------------------------------------------- 1 | --retain=g_pfnVectors 2 | 3 | #include "autoconf.h" 4 | 5 | --heap_size=20480 6 | --stack_size=4096 7 | 8 | #define APP_BASE 0x00000000 9 | #define RAM_BASE 0x20000000 10 | 11 | /* System memory map */ 12 | 13 | MEMORY 14 | { 15 | /* Application stored in and executes from internal flash */ 16 | FLASH (RX) : origin = APP_BASE, length = 0x00040000 17 | /* Application uses internal RAM for data */ 18 | SRAM (RWX) : origin = 0x20000000, length = 0x00008000 19 | } 20 | 21 | /* Section allocation in memory */ 22 | 23 | SECTIONS 24 | { 25 | .intvecs: > APP_BASE 26 | .text : > FLASH 27 | .const : > FLASH 28 | .cinit : > FLASH 29 | .pinit : > FLASH 30 | .init_array : > FLASH 31 | 32 | .vtable : > RAM_BASE 33 | .data : > SRAM 34 | .bss : > SRAM 35 | .sysmem : > SRAM 36 | .stack : > SRAM 37 | } 38 | 39 | _stack_top = __stack + 512; 40 | -------------------------------------------------------------------------------- /platform/arm/ti/lm3s6965/lm3s6965.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/lm3s6965/lm3s6965.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/ti/lm4f120xl/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=lm4f120xl.o interrupts.o 2 | 3 | ifneq ($(CONFIG_TI_CCS5),) 4 | LINKER_SCRIPT:=$(d)/lm4f120xl.cmd 5 | CFLAGS+=-mv7M4 --code_state=16 --float_support=FPv4SPD16 \ 6 | --define=PART_LM4F120H5QR --define=TARGET_IS_BLIZZARD_RA1 7 | LDFLAGS+=-mv7M4 8 | endif 9 | 10 | ifneq ($(CONFIG_GCC),) 11 | MK_OBJS+=entry_gcc.o 12 | 13 | LINKER_SCRIPT:=$(BUILD)/$(d)/lm4f120xl.ld 14 | CFLAGS+=-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -O3 \ 15 | -ffunction-sections -fdata-sections -DPART_LM4F120H5QR \ 16 | -I$(TI_ARM_MCU_BSP_DIR) -DTARGET_IS_BLIZZARD_RA1 -Dgcc \ 17 | -fsingle-precision-constant 18 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 19 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 20 | endif 21 | -------------------------------------------------------------------------------- /platform/arm/ti/lm4f120xl/lm4f120xl.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(lm4f120xl) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 256K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 32K) 6 | 7 | /* UART (num, rx, tx) */ 8 | TI_UART_DEF(0, PA0, PA1) 9 | TI_UART_DEF(1, PB0, PB1) 10 | TI_UART_DEF(2, PD6, PD7) 11 | TI_UART_DEF(3, PC6, PC7) 12 | TI_UART_DEF(4, PC4, PC5) 13 | TI_UART_DEF(5, PE4, PE5) 14 | TI_UART_DEF(6, PD4, PD5) 15 | TI_UART_DEF(7, PE0, PE1) 16 | 17 | /* SSI (num, clkpin, fsspin, rxpin, txpin) */ 18 | TI_SSI_DEF(0, PA2, PA3, PA4, PA5) 19 | TI_SSI_DEF(1, PD0, PD1, PD2, PD3) 20 | 21 | /* I2C (num, sclpin, sdapin) */ 22 | TI_I2C_DEF(0, PB2, PB3) 23 | TI_I2C_DEF(1, PA6, PA7) 24 | TI_I2C_DEF(2, PE4, PE5) 25 | TI_I2C_DEF(3, PD0, PD1) 26 | 27 | /* USBD (dp, dm) */ 28 | TI_USBD_DEF(PD5, PD4) 29 | 30 | CHIPSET_END() 31 | -------------------------------------------------------------------------------- /platform/arm/ti/lm4f120xl/lm4f120xl.cmd: -------------------------------------------------------------------------------- 1 | --retain=g_pfnVectors 2 | 3 | #include "autoconf.h" 4 | 5 | --heap_size=20480 6 | --stack_size=4096 7 | 8 | #define APP_BASE 0x00000000 9 | #define RAM_BASE 0x20000000 10 | 11 | /* System memory map */ 12 | 13 | MEMORY 14 | { 15 | /* Application stored in and executes from internal flash */ 16 | FLASH (RX) : origin = APP_BASE, length = 0x00040000 17 | /* Application uses internal RAM for data */ 18 | SRAM (RWX) : origin = 0x20000000, length = 0x00008000 19 | } 20 | 21 | /* Section allocation in memory */ 22 | 23 | SECTIONS 24 | { 25 | .intvecs: > APP_BASE 26 | .text : > FLASH 27 | .const : > FLASH 28 | .cinit : > FLASH 29 | .pinit : > FLASH 30 | .init_array : > FLASH 31 | 32 | .vtable : > RAM_BASE 33 | .data : > SRAM 34 | .bss : > SRAM 35 | .sysmem : > SRAM 36 | .stack : > SRAM 37 | } 38 | 39 | _stack_top = __stack + 512; 40 | -------------------------------------------------------------------------------- /platform/arm/ti/lm4f120xl/lm4f120xl.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/lm4f120xl/lm4f120xl.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/ti/stellaris_eth.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __STELLARIS_ETH_H__ 26 | #define __STELLARIS_ETH_H__ 27 | 28 | #include "net/netif.h" 29 | 30 | int stellaris_eth_event_process(void); 31 | 32 | netif_t *stellaris_eth_new(void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /platform/arm/ti/stellaris_eth.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("StellarisEth", netif, do_stellaris_eth_constructor, { 2 | .params = { 3 | }, 4 | .description = "Stellaris Ethernet Object Constructor", 5 | .return_value = "Created object", 6 | .example = "var enc = new StellarisEth();\n" 7 | "console.log('link status: ' + enc.linkStatus() ? 'connected' : " 8 | "'disconnected');", 9 | }) 10 | -------------------------------------------------------------------------------- /platform/arm/ti/tiva_c_emac.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __TIVA_C_EMAC_H__ 26 | #define __TIVA_C_EMAC_H__ 27 | 28 | #include "net/netif.h" 29 | 30 | int tiva_c_emac_event_process(void); 31 | 32 | netif_t *tiva_c_emac_new(void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c123g/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=tm4c123g.o interrupts.o 2 | 3 | ifneq ($(CONFIG_GCC),) 4 | BSP_SRCS:=gpio.c $(if $(CONFIG_USB),usb.c) 5 | MK_LINKS:=$(addprefix $(TI_ARM_MCU_BSP_DIR)/driverlib/,$(BSP_SRCS)) 6 | MK_OBJS+=entry_gcc.o $(BSP_SRCS:%.c=%.o) 7 | 8 | LINKER_SCRIPT:=$(BUILD)/$(d)/tm4c123g.ld 9 | CFLAGS+=-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -O3 \ 10 | -ffunction-sections -fdata-sections -I$(TI_ARM_MCU_BSP_DIR) \ 11 | -DPART_TM4C123GH6PM -DTARGET_IS_TM4C123_RB1 \ 12 | -Dgcc -fsingle-precision-constant 13 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 14 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 15 | endif 16 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c123g/tm4c123g.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(tm4c123g) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 256K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 32K) 6 | 7 | /* UART (num, rx, tx) */ 8 | TI_UART_DEF(0, PA0, PA1) 9 | TI_UART_DEF(1, PB0, PB1) 10 | TI_UART_DEF(2, PD6, PD7) 11 | TI_UART_DEF(3, PC6, PC7) 12 | TI_UART_DEF(4, PC4, PC5) 13 | TI_UART_DEF(5, PE4, PE5) 14 | TI_UART_DEF(6, PD4, PD5) 15 | TI_UART_DEF(7, PE0, PE1) 16 | 17 | /* SSI (num, clkpin, fsspin, rxpin, txpin) */ 18 | TI_SSI_DEF(0, PA2, PA3, PA4, PA5) 19 | TI_SSI_DEF(1, PD0, PD1, PD2, PD3) 20 | 21 | /* I2C (num, sclpin, sdapin) */ 22 | TI_I2C_DEF(0, PB2, PB3) 23 | TI_I2C_DEF(1, PA6, PA7) 24 | TI_I2C_DEF(2, PE4, PE5) 25 | TI_I2C_DEF(3, PD0, PD1) 26 | 27 | /* PWM (_pin, _base, _gen, _bit) */ 28 | TI_PWM_DEF(PB6, 0, 0, 0) 29 | TI_PWM_DEF(PB7, 0, 0, 1) 30 | TI_PWM_DEF(PB4, 0, 1, 2) 31 | TI_PWM_DEF(PB5, 0, 1, 3) 32 | TI_PWM_DEF(PE4, 0, 2, 4) 33 | TI_PWM_DEF(PE5, 0, 2, 5) 34 | TI_PWM_DEF(PC4, 0, 3, 6) 35 | TI_PWM_DEF(PC5, 0, 3, 7) 36 | TI_PWM_DEF(PD0, 1, 0, 0) 37 | TI_PWM_DEF(PD1, 1, 0, 1) 38 | TI_PWM_DEF(PA6, 1, 1, 2) 39 | TI_PWM_DEF(PA7, 1, 1, 3) 40 | TI_PWM_DEF(PF0, 1, 2, 4) 41 | TI_PWM_DEF(PF1, 1, 2, 5) 42 | TI_PWM_DEF(PF2, 1, 3, 6) 43 | TI_PWM_DEF(PF3, 1, 3, 7) 44 | 45 | /* USBD (dp, dm) */ 46 | TI_USBD_DEF(PD5, PD4) 47 | 48 | CHIPSET_END() 49 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c123g/tm4c123g.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/tm4c123g/tm4c123g.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c1294/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=tm4c1294.o interrupts.o 2 | 3 | ifneq ($(CONFIG_GCC),) 4 | BSP_SRCS:=systick.c sysctl.c gpio.c interrupt.c uart.c ssi.c cpu.c adc.c \ 5 | pwm.c emac.c $(if $(CONFIG_I2C),i2c.c) $(if $(CONFIG_USB_DEVICE),usb.c) 6 | 7 | MK_LINKS:=$(addprefix $(TI_ARM_MCU_BSP_DIR)/driverlib/,$(BSP_SRCS)) 8 | MK_OBJS+=entry_gcc.o $(BSP_SRCS:%.c=%.o) 9 | 10 | LINKER_SCRIPT:=$(BUILD)/$(d)/tm4c1294.ld 11 | CFLAGS+=-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -O3 \ 12 | -ffunction-sections -fdata-sections -I$(TI_ARM_MCU_BSP_DIR) \ 13 | -DPART_TM4C1294NCPDT -Dgcc -fsingle-precision-constant 14 | LDFLAGS+=--entry reset_isr --gc-sections --nostdlib 15 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 16 | endif 17 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c1294/tm4c1294.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(tm4c1294) 2 | 3 | /* MEMORY */ 4 | ARM_MEMORY_AREA(FLASH, rx, 0x00000000, 1024K) 5 | ARM_MEMORY_AREA(SRAM, rwx, 0x20000000, 256K) 6 | 7 | /* UART (num, rx, tx) */ 8 | TI_UART_DEF(0, PA0, PA1) 9 | TI_UART_DEF(1, PB0, PB1) 10 | TI_UART_DEF(2, PA6, PA7) 11 | TI_UART_DEF(3, PA4, PA5) 12 | TI_UART_DEF(4, PA2, PA3) 13 | TI_UART_DEF(5, PC6, PC7) 14 | TI_UART_DEF(6, PP0, PP1) 15 | TI_UART_DEF(7, PC4, PC5) 16 | 17 | /* SSI (num, clkpin, fsspin, rxpin, txpin) */ 18 | TI_SSI_DEF(0, PA2, PA3, PA4, PA5) 19 | TI_SSI_DEF(1, PB5, PB4, PE4, PE5) 20 | TI_SSI_DEF(2, PD3, PD2, PD1, PD0) 21 | 22 | /* I2C (num, sclpin, sdapin) */ 23 | TI_I2C_DEF(0, PB2, PB3) 24 | TI_I2C_DEF(1, PG0, PG1) 25 | TI_I2C_DEF(2, PN5, PN4) 26 | TI_I2C_DEF(3, PK4, PK5) 27 | TI_I2C_DEF(4, PK6, PK7) 28 | TI_I2C_DEF(5, PB0, PB1) 29 | TI_I2C_DEF(6, PA6, PA7) 30 | TI_I2C_DEF(7, PA4, PA5) 31 | TI_I2C_DEF(8, PA2, PA3) 32 | TI_I2C_DEF(9, PA0, PA1) 33 | 34 | /* PWM (_pin, _base, _gen, _bit) */ 35 | TI_PWM_DEF(PF0, 0, 0, 0) 36 | TI_PWM_DEF(PF1, 0, 0, 1) 37 | TI_PWM_DEF(PF2, 0, 1, 2) 38 | TI_PWM_DEF(PF3, 0, 1, 3) 39 | TI_PWM_DEF(PG0, 0, 2, 4) 40 | TI_PWM_DEF(PG1, 0, 2, 5) 41 | TI_PWM_DEF(PK4, 0, 3, 6) 42 | TI_PWM_DEF(PK5, 0, 3, 7) 43 | 44 | /* USBD (dp, dm) */ 45 | TI_USBD_DEF(PL6, PL7) 46 | 47 | CHIPSET_END() 48 | -------------------------------------------------------------------------------- /platform/arm/ti/tm4c1294/tm4c1294.ld.S: -------------------------------------------------------------------------------- 1 | _stack_size = 4K; 2 | 3 | #define PLATFORM_CHIPSET_H "platform/arm/ti/tm4c1294/tm4c1294.chip" 4 | 5 | #include "platform/arm/cortex-m.ld.S" 6 | -------------------------------------------------------------------------------- /platform/avr8/Kconfig: -------------------------------------------------------------------------------- 1 | config AVR8 2 | bool 3 | select PLAT_HAS_GCC 4 | select PLAT_HAS_GPIO 5 | select PLAT_HAS_MALLOC 6 | select PLAT_HAS_SERIAL 7 | select PLAT_HAS_I2C 8 | select BUFFERED_SERIAL 9 | select PLAT_TICKS 10 | select 16_BIT 11 | 12 | config ATMEGA328 13 | bool 14 | select AVR8 15 | -------------------------------------------------------------------------------- /platform/avr8/Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(CONFIG_ATMEGA328),) 2 | MK_OBJS+=atmega328.o 3 | MK_OBJS+=$(if $(CONFIG_I2C),atmega328_i2c.o) 4 | CFLAGS+=-mmcu=atmega328p -Os --function-sections 5 | LDFLAGS+=-mmcu=atmega328p -Wl,--gc-sections 6 | endif 7 | -------------------------------------------------------------------------------- /platform/avr8/atmega328_i2c.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __ATMEGA328_I2C_H__ 26 | #define __ATMEGA328_I2C_H__ 27 | 28 | int avr8_i2c_init(int port); 29 | void avr8_i2c_reg_write(int port, unsigned char addr, unsigned char reg, 30 | const unsigned char *data, int len); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /platform/chipset.h: -------------------------------------------------------------------------------- 1 | #ifndef CHIPSET_START 2 | #define CHIPSET_START(...) 3 | #endif 4 | 5 | /* MEMORY */ 6 | #ifndef ARM_MEMORY_AREA 7 | #define ARM_MEMORY_AREA(...) 8 | #endif 9 | 10 | /* UARTS */ 11 | #ifndef TI_UART_DEF 12 | #define TI_UART_DEF(...) 13 | #endif 14 | #ifndef STM32_USART_DEF 15 | #define STM32_USART_DEF(...) 16 | #endif 17 | #ifndef MSP430_USCI_DEF 18 | #define MSP430_USCI_DEF(...) 19 | #endif 20 | 21 | /* SPI */ 22 | #ifndef TI_SSI_DEF 23 | #define TI_SSI_DEF(...) 24 | #endif 25 | #ifndef STM32_SPI_DEF 26 | #define STM32_SPI_DEF(...) 27 | #endif 28 | 29 | /* I2C */ 30 | #ifndef TI_I2C_DEF 31 | #define TI_I2C_DEF(...) 32 | #endif 33 | #ifndef STM32_I2C_DEF 34 | #define STM32_I2C_DEF(...) 35 | #endif 36 | 37 | /* PWM */ 38 | #ifndef TI_PWM_DEF 39 | #define TI_PWM_DEF(...) 40 | #endif 41 | 42 | /* USBD */ 43 | #ifndef TI_USBD_DEF 44 | #define TI_USBD_DEF(...) 45 | #endif 46 | 47 | #ifndef CHIPSET_END 48 | #define CHIPSET_END(...) 49 | #endif 50 | 51 | #include PLATFORM_CHIPSET_H 52 | 53 | #undef CHIPSET_START 54 | #undef ARM_MEMORY_AREA 55 | #undef TI_UART_DEF 56 | #undef STM32_USART_DEF 57 | #undef MSP430_USCI_DEF 58 | #undef TI_SSI_DEF 59 | #undef STM32_SPI_DEF 60 | #undef TI_I2C_DEF 61 | #undef STM32_I2C_DEF 62 | #undef TI_PWM_DEF 63 | #undef TI_USBD_DEF 64 | #undef CHIPSET_END 65 | -------------------------------------------------------------------------------- /platform/esp8266/Kconfig: -------------------------------------------------------------------------------- 1 | config ESP8266 2 | bool 3 | select PLAT_HAS_GCC 4 | select PLAT_HAS_OWN_MALLOC 5 | select PLAT_HAS_SERIAL 6 | select BUFFERED_SERIAL 7 | select PLAT_TICKS 8 | 9 | config ESP8266_WIFI 10 | bool "Wi-Fi Support" 11 | depends on ESP8266 && NET 12 | -------------------------------------------------------------------------------- /platform/esp8266/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(ESP8266_SDK_BASE),) 2 | $(error Please set ESP8266_SDK_BASE environment variable) 3 | endif 4 | 5 | ESPTOOL=esptool.py 6 | 7 | MK_OBJS+=esp8266.o 8 | ifneq ($(CONFIG_ESP8266_WIFI),) 9 | MK_OBJS+=esp8266_wifi.o $(if $(CONFIG_JS),js_esp8266_wifi.o) 10 | MK_JSAPIS=esp8266_wifi.jsapi 11 | endif 12 | 13 | CFLAGS+=-fno-builtin -fno-strict-aliasing -mlongcalls \ 14 | -mtext-section-literals -D__ets__ -DICACHE_FLASH -Wl,EL \ 15 | -fno-inline-functions -nostdlib 16 | 17 | ADDITIONAL_INCLUDE_PATHS+=$(ESP8266_SDK_BASE)/sdk/include \ 18 | $(ESP8266_SDK_BASE)/sdk/examples/driver_lib/include/driver $(d) 19 | 20 | LINKER_SCRIPT=$(ESP8266_SDK_BASE)/sdk/ld/eagle.app.v6.ld 21 | 22 | LDFLAGS+=-L$(ESP8266_SDK_BASE)/sdk/lib -T$(LINKER_SCRIPT) -u call_user_start \ 23 | -nostdlib -EL 24 | 25 | LIBS+=-L$(call get_libc_dir) -lc -L$(call get_libgcc_dir) -lgcc \ 26 | -L$(call get_lib_dir,hal) -lhal -lpp -lphy -lnet80211 -llwip -lwpa -lmain 27 | 28 | IMAGE_NAME:=tp-0x00000.bin tp-0x40000.bin 29 | 30 | INTRM_TARGET=$(BUILD)/interim.o 31 | 32 | AUTO_GEN_FILES+=$(INTRM_TARGET) 33 | 34 | # Linkage trickery: 35 | # - Would like to use the SDK provided linker script 36 | # - The SDK linker script places .text in iram1_0 seg which is quite 37 | # small (e.g. 32KB) 38 | # - So place the .text section in irom_0_0_seg by renaming it to 39 | # .irom0.text after partial linking 40 | define target_link 41 | @echo LD $@ 42 | $(Q)$(LD) --no-check-sections -static -r -o $(INTRM_TARGET) \ 43 | $(OBJS) 44 | $(Q)$(OBJCOPY) --rename-section .text=.irom0.text $(INTRM_TARGET) 45 | $(Q)$(LD) $(LDFLAGS) -o $@ $(INTRM_TARGET) --start-group $(LIBS) --end-group 46 | $(Q)rm $(INTRM_TARGET) 47 | endef 48 | 49 | gen_image=$(ESPTOOL) elf2image $^ 50 | -------------------------------------------------------------------------------- /platform/esp8266/esp8266.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __ESP8266_CONSTS_H__ 26 | #define __ESP8266_CONSTS_H__ 27 | 28 | #define NUM_UARTS 1 29 | #define UART0 0 30 | 31 | #define NUM_GPIO_PORTS 0 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /platform/esp8266/esp8266_wifi.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __ESP8266_WIFI_H__ 26 | #define __ESP8266_WIFI_H__ 27 | 28 | netif_t *esp8266_wifi_new(void); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /platform/esp8266/esp8266_wifi.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("ESP8266_WIFI", netif, do_esp8266_wifi_constructor, { 2 | .params = { 3 | }, 4 | .description = "ESP8266 Wi-Fi Constructor", 5 | .return_value = "Created object", 6 | .example = "var esp = new ESP8266_WIFI();\n" 7 | "esp.IPConnect();\n" 8 | }) 9 | -------------------------------------------------------------------------------- /platform/esp8266/user_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/platform/esp8266/user_config.h -------------------------------------------------------------------------------- /platform/msp430/Kconfig: -------------------------------------------------------------------------------- 1 | config MSP430 2 | bool 3 | select PLAT_HAS_TI_CCS5 4 | select PLAT_HAS_GCC 5 | select PLAT_HAS_MALLOC 6 | select PLAT_TICKS 7 | select 16_BIT 8 | 9 | config MSP430F5529 10 | bool 11 | select MSP430 12 | select PLAT_HAS_GPIO 13 | select PLAT_HAS_SERIAL 14 | select PLAT_HAS_SPI 15 | select PLAT_HAS_GPIO_INTERRUPTS 16 | select BUFFERED_SERIAL 17 | 18 | -------------------------------------------------------------------------------- /platform/msp430/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS=msp430f5529.o msp430f5529_usci.o 2 | MK_OBJS+=$(if $(CONFIG_GPIO),msp430f5529_gpio.o) 3 | MK_OBJS+=$(if $(CONFIG_SPI),msp430f5529_spi.o) 4 | 5 | ifneq ($(CONFIG_TI_CCS5),) 6 | TI_COMPILER:=$(TI_CCS5)/tools/compiler/msp430_4.1.1 7 | CC=$(TI_COMPILER)/bin/cl430 8 | LINKER_SCRIPT:=$(d)/lnk_msp430f5529.cmd 9 | CFLAGS+=$(if $(POWER_DBG),--advice:power=all) 10 | CFLAGS+=-vmspx --abi=eabi --define=__MSP430F5529__ \ 11 | --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 \ 12 | --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=minimal \ 13 | --include_path="$(TI_CCS5)/ccs_base/msp430/include" 14 | LDFLAGS+=-vmspx --abi=eabi -g -i"$(TI_CCS5)/ccs_base/msp430/include" 15 | LIBS+=-l"libc.a" 16 | endif 17 | 18 | ifneq ($(CONFIG_GCC),) 19 | MSP_DIR=$(dir $(CROSS_COMPILE)).. 20 | CFLAGS+=-mmcu=msp430f5529 -I$(MSP_DIR)/include -Os 21 | LDFLAGS+=-mmcu=msp430f5529 -L$(MSP_DIR)/include 22 | endif 23 | -------------------------------------------------------------------------------- /platform/msp430/msp430f5529.chip: -------------------------------------------------------------------------------- 1 | CHIPSET_START(msp430f5529) 2 | 3 | /* MSP430_USCI(id, rx, tx, clk) */ 4 | 5 | MSP430_USCI_DEF(A0, PC4, PC3, PB7) 6 | MSP430_USCI_DEF(A1, PD5, PD4, PD0) 7 | MSP430_USCI_DEF(B0, PC1, PC0, PC2) 8 | MSP430_USCI_DEF(B1, PD2, PD1, PD3) 9 | 10 | CHIPSET_END() 11 | -------------------------------------------------------------------------------- /platform/ticks.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __TICKS_H__ 26 | #define __TICKS_H__ 27 | 28 | #include 29 | 30 | static inline void tick(void) 31 | { 32 | extern volatile uint32_t ticks; 33 | 34 | ticks++; 35 | } 36 | 37 | void gen_get_time_from_boot(uint32_t *sec, uint32_t *usec); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /platform/unix/Kconfig: -------------------------------------------------------------------------------- 1 | config UNIX 2 | bool 3 | select PLAT_HAS_MALLOC 4 | select PLAT_HAS_GCC 5 | 6 | if UNIX 7 | 8 | menu "Platform Emulation Options" 9 | 10 | config PLATFORM_EMULATION_PTY_TERM 11 | bool "PTY Serial Device" 12 | default y 13 | 14 | config PLATFORM_EMULATION_EXT_TTY 15 | bool "Extenal TTY Serial Device" 16 | default y 17 | 18 | config PLATFORM_EMULATION_EXT_TTY_PATH 19 | string "External TTY path" 20 | depends on PLATFORM_EMULATION_EXT_TTY 21 | default "/dev/ttyACM0" 22 | 23 | config PLATFORM_EMULATION_BLOCK_DISK 24 | bool "Block Disk Emulation" 25 | default y 26 | select PLAT_HAS_BLK 27 | 28 | config PLATFORM_EMULATION_BLOCK_DISK_PATH 29 | string "Block Disk Path" 30 | depends on PLATFORM_EMULATION_BLOCK_DISK 31 | default "/tmp/tp_block_disk.img" 32 | 33 | config PLATFORM_EMULATION_BLOCK_DISK_NUM_SECTORS 34 | int "Block Disk Number of Sectors" 35 | depends on PLATFORM_EMULATION_BLOCK_DISK 36 | default 2048 37 | 38 | config NETIF_INET 39 | bool "Network Interface Using INET Sockets" 40 | depends on PLATFORM_EMULATION && NET 41 | default y 42 | 43 | config LINUX_ETH 44 | bool "Linux User Mode Ethernet using Packet Socket" 45 | depends on PLATFORM_EMULATION && NET 46 | select ETHERIF 47 | default n 48 | help 49 | Packet sockets allow raw Ethernet packet send/receive 50 | Selecting this option requires running the process on Linux with 51 | root permissions 52 | 53 | endmenu 54 | endif 55 | -------------------------------------------------------------------------------- /platform/unix/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=$(if $(CONFIG_PLATFORM_EMULATION),sim.o) 2 | MK_OBJS+=$(if $(CONFIG_UNIX),unix.o) 3 | 4 | ifneq ($(CONFIG_NETIF_INET),) 5 | MK_OBJS+=netif_inet.o $(if $(CONFIG_JS),js_netif_inet.o) 6 | MK_JSAPIS=netif_inet.jsapi 7 | endif 8 | 9 | ifneq ($(CONFIG_LINUX_ETH),) 10 | MK_OBJS+=linux_eth.o $(if $(CONFIG_JS),js_linux_eth.o) 11 | MK_JSAPIS=linux_eth.jsapi 12 | endif 13 | 14 | LIBS+=-lm 15 | -------------------------------------------------------------------------------- /platform/unix/linux_eth.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __LINUX_PACKET_ETH_H__ 26 | #define __LINUX_PACKET_ETH_H__ 27 | 28 | #include "net/netif.h" 29 | 30 | netif_t *linux_eth_new(char *dev_name); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /platform/unix/linux_eth.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("LinuxPacketEth", netif, do_linux_eth_constructor, { 2 | .params = { 3 | { .name = "Net Device", .description = "Linux Network Interface Name" }, 4 | }, 5 | .description = "Linux Packet Ethernet Object Constructor", 6 | .return_value = "Created object", 7 | .example = "var n = new LinuxPacketEth('eth0');\n" 8 | "console.log('link status: ' + n.linkStatus() ? 'connected' : " 9 | "'disconnected');", 10 | }) 11 | -------------------------------------------------------------------------------- /platform/unix/netif_inet.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __NETIF_INET_H__ 26 | #define __NETIF_INET_H__ 27 | 28 | #include "net/netif.h" 29 | 30 | netif_t *netif_inet_new(char *dev_name); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /platform/unix/netif_inet.jsapi: -------------------------------------------------------------------------------- 1 | CONSTRUCTOR("NetifINET", netif, do_netif_inet_constructor, { 2 | .params = { 3 | { .name = "Net Device", .description = "Network Interface Name" }, 4 | }, 5 | .description = "INET Network Interface Object Constructor", 6 | .return_value = "Created object", 7 | .example = "var n = new NetifINET('eth0');\n" 8 | "console.log('link status: ' + n.linkStatus() ? 'connected' : " 9 | "'disconnected');", 10 | }) 11 | -------------------------------------------------------------------------------- /platform/x86/Kconfig: -------------------------------------------------------------------------------- 1 | config X86 2 | bool 3 | select PLAT_HAS_MALLOC 4 | select PLAT_HAS_GCC 5 | -------------------------------------------------------------------------------- /platform/x86/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=x86.o vga_term.o boot.o 2 | 3 | ifneq ($(CONFIG_GCC),) 4 | LINKER_SCRIPT:=$(BUILD)/$(d)/x86.ld 5 | LDFLAGS+=--entry _start --gc-sections --nostdlib 6 | LIBS+=-L$(call get_libc_dir) -lm -lc -L$(call get_libgcc_dir) -lgcc 7 | endif 8 | -------------------------------------------------------------------------------- /platform/x86/boot.s: -------------------------------------------------------------------------------- 1 | # Multiboot magic tricks 2 | .set ALIGN, 1<<0 3 | .set MEMINFO, 1<<1 4 | .set FLAGS, ALIGN | MEMINFO 5 | .set MAGIC, 0x1BADB002 6 | .set CHECKSUM, -(MAGIC + FLAGS) 7 | 8 | # Multiboot header 9 | .section .multiboot 10 | .align 4 11 | .long MAGIC 12 | .long FLAGS 13 | .long CHECKSUM 14 | 15 | # Entry point 16 | .section .text 17 | .global _start 18 | .type _start, @function 19 | _start: 20 | # Setup stack 21 | movl $_stack_top, %esp 22 | 23 | # XXX: zero BSS 24 | 25 | # Go to C entry point 26 | call kernel_main 27 | 28 | # We should never get here 29 | cli 30 | hlt 31 | .hang: 32 | jmp .hang 33 | -------------------------------------------------------------------------------- /platform/x86/vga_term.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __VGA_TERM_H__ 26 | #define __VGA_TERM_H__ 27 | 28 | void vga_term_init(void); 29 | void vga_term_putchar(char c); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /platform/x86/x86.ld.S: -------------------------------------------------------------------------------- 1 | SECTIONS 2 | { 3 | /* Load address at 1M */ 4 | . = 1M; 5 | 6 | .text BLOCK(4K) : ALIGN(4K) 7 | { 8 | /* Multiboot header */ 9 | *(.multiboot) 10 | *(.text) 11 | } 12 | 13 | .rodata BLOCK(4K) : ALIGN(4K) 14 | { 15 | *(.rodata) 16 | } 17 | 18 | .data BLOCK(4K) : ALIGN(4K) 19 | { 20 | *(.data) 21 | } 22 | 23 | .bss BLOCK(4K) : ALIGN(4K) 24 | { 25 | _bss = .; 26 | *(.bss*) 27 | *(COMMON) 28 | _ebss = .; 29 | } 30 | _heap_bottom = .; 31 | 32 | _heap_top = _heap_bottom + 128K; 33 | 34 | _stack_top = _heap_top + 4K; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /scripts/Makefile.config: -------------------------------------------------------------------------------- 1 | STAGING=staging.$(HOST_OS) 2 | CONFIG_SRC=scripts/kconfig 3 | export CONFIG=staging.$(HOST_OS)/kconfig 4 | MCONF = $(CONFIG)/mconf 5 | CONF = $(CONFIG)/conf 6 | CONFIG_BUILDDIRS = $(CONFIG) $(CONFIG)/lxdialog 7 | 8 | $(CONFIG_BUILDDIRS): 9 | $(Q)mkdir -p $(CONFIG_BUILDDIRS) 10 | 11 | $(MCONF): | $(CONFIG_BUILDDIRS) 12 | @echo "Building $@" 13 | $(Q)make -C $(CONFIG_SRC) menuconfig $(if $(Q),> /dev/null) 14 | 15 | $(CONF): | $(CONFIG_BUILDDIRS) 16 | @echo "Building $@" 17 | $(Q)make -C $(CONFIG_SRC) $(if $(Q),> /dev/null) 18 | 19 | menuconfig: build_dir $(MCONF) 20 | $(Q)KCONFIG_CONFIG=$(BUILD)/.config $(MCONF) Kconfig 21 | 22 | config: build_dir $(CONF) 23 | $(Q)KCONFIG_CONFIG=$(BUILD)/.config $(CONF) Kconfig 24 | 25 | %_defconfig: build_dir $(CONF) 26 | @echo "*** Default configuration is based on '$@'" 27 | $(Q)KCONFIG_CONFIG=$(BUILD)/.config $(CONF) --defconfig=boards/configs/$@ Kconfig 28 | 29 | $(BUILD)/.config: 30 | $(Q)make menuconfig 31 | 32 | -include $(BUILD)/auto.conf.cmd 33 | 34 | $(BUILD)/auto.conf: $(CONF) $(BUILD)/.config 35 | $(Q)KCONFIG_AUTOCONFIG=$(BUILD)/auto.conf \ 36 | KCONFIG_AUTOCONFIG_DEP=$(BUILD)/auto.conf.cmd \ 37 | KCONFIG_TRISTATE=$(BUILD)/tristate.conf \ 38 | KCONFIG_CONFIG=$(BUILD)/.config \ 39 | KCONFIG_AUTOHEADER=$(BUILD)/autoconf.h $(CONF) --silentoldconfig Kconfig 40 | 41 | $(BUILD)/autoconf.h: $(BUILD)/auto.conf 42 | 43 | .PHONY: staging_dir config menuconfig %_defconfig 44 | -------------------------------------------------------------------------------- /scripts/Makefile.toolchain: -------------------------------------------------------------------------------- 1 | TOOLCHAIN_MKS+=$(if $(CONFIG_GCC),gcc.mk) 2 | TOOLCHAIN_MKS+=$(if $(CONFIG_TI_CCS5),ti_ccs5.mk) 3 | 4 | include $(addprefix scripts/,$(TOOLCHAIN_MKS)) 5 | -------------------------------------------------------------------------------- /scripts/Rules.mk: -------------------------------------------------------------------------------- 1 | define include_dir 2 | dir_stack := $(d) $(dir_stack) 3 | d := $(d)/$(1) 4 | include scripts/header.mk 5 | include $(addsuffix /Makefile,$$(d)) 6 | include scripts/footer.mk 7 | d := $$(firstword $$(dir_stack)) 8 | dir_stack := $$(wordlist 2,$$(words $$(dir_stack)),$$(dir_stack)) 9 | endef 10 | 11 | # $1 target 12 | # $2 source 13 | define link_target 14 | 15 | AUTO_GEN_FILES+=$1 16 | 17 | $1 :: $2 18 | @echo "LN $1" 19 | $(Q)ln -sf $(shell pwd)/$2 $1 20 | 21 | endef 22 | -------------------------------------------------------------------------------- /scripts/build_dist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | host_os=`uname`; 3 | target=$1; 4 | binpath=$2; 5 | version=$3; 6 | binfile_suffix=$4; 7 | 8 | echo "Building $target $version"; 9 | 10 | make ${target}_gcc_defconfig; 11 | source build.$host_os/.config; 12 | make; 13 | cp build.$host_os/tp${binfile_suffix} $binpath/tinkerpal-v$version-${target}${binfile_suffix}; 14 | make distclean; 15 | -------------------------------------------------------------------------------- /scripts/coveralls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ "$DEFCONFIG" == "unix_sim_tests_defconfig" ] && { 4 | coveralls --exclude build.Linux/fs/fat/ff.c --exclude staging.Linux --exclude doc --exclude scripts --exclude tests --gcov-options '\-lp' -r . -b . 5 | bash <(curl -s https://codecov.io/bash) 6 | } 7 | -------------------------------------------------------------------------------- /scripts/defaults.mk: -------------------------------------------------------------------------------- 1 | define target_link_default 2 | @echo $($(quiet_)link) 3 | @$(call link) 4 | endef 5 | 6 | define target_link 7 | @$(call target_link_default) 8 | endef 9 | -------------------------------------------------------------------------------- /scripts/footer.mk: -------------------------------------------------------------------------------- 1 | OBJS:=$(OBJS) $(addprefix $(BUILD)/$(d)/,$(MK_OBJS)) 2 | JSAPIS:=$(JSAPIS) $(addprefix $(d)/,$(MK_JSAPIS)) 3 | BUILTIN_FS_INTERNAL_FILES:=$(BUILTIN_FS_INTERNAL_FILES) $(addprefix $(d)/,$(MK_BUILTIN_FS_INTERNAL_FILES)) 4 | ADDITIONAL_INCLUDE_PATHS:=$(ADDITIONAL_INCLUDE_PATHS) $(addprefix $(d)/,$(MK_ADDITIONAL_INCLUDE_PATHS)) 5 | ADDITIONAL_INCLUDES:=$(ADDITIONAL_INCLUDES) $(addprefix $(d)/,$(MK_ADDITIONAL_INCLUDES)) 6 | 7 | $(foreach o,$(MK_OBJS),\ 8 | $(eval MK_CFLAGS_$(BUILD)/$(d)/$(o)=$(MK_CFLAGS_$(o)))) 9 | 10 | $(foreach m,$(MK_INCLUDES),\ 11 | $(eval include $(addsuffix /$m,$(d)))) 12 | 13 | $(foreach s,$(MK_SUBDIRS),\ 14 | $(eval $(call include_dir,$s))) 15 | 16 | $(foreach l,$(MK_LINKS),\ 17 | $(eval $(call link_target,$(BUILD)/$(d)/$(notdir $l),$l))) 18 | -------------------------------------------------------------------------------- /scripts/gcc.mk: -------------------------------------------------------------------------------- 1 | CROSS_COMPILE?=$(CONFIG_CROSS_COMPILE:"%"=%) 2 | 3 | $(info ==== Using $(if $(CROSS_COMPILE),Cross,Local) GCC environment ====) 4 | 5 | CC=$(CROSS_COMPILE)gcc 6 | # Note: we use gcc as ld on Unix builds so that we get crtX.o paths 7 | LD=$(if $(CONFIG_UNIX)$(CONFIG_16_BIT),$(CC),$(CROSS_COMPILE)ld) 8 | OBJCOPY=$(CROSS_COMPILE)objcopy 9 | CPP=$(CROSS_COMPILE)cpp 10 | AS=$(CROSS_COMPILE)as 11 | #LDFLAGS+=$(if $(CONFIG_UNIX),-Wl,)-Map=$@.map 12 | LINK_DEPS=$(LINKER_SCRIPT) 13 | 14 | CFLAGS+=-I. -I$(BUILD) -include $(BUILD)/autoconf.h \ 15 | $(addprefix -include ,$(ADDITIONAL_INCLUDES)) \ 16 | $(addprefix -I,$(ADDITIONAL_INCLUDE_PATHS)) \ 17 | -Wall -Werror -g -ansi -std=gnu99 $(if $(CONFIG_GCC_LTO),-flto) \ 18 | $(if $(CONFIG_GCC_GCOV),--coverage) $(if $(CONFIG_GCC_CAST_QUAL),-Wcast-qual) 19 | LDFLAGS+=$(if $(CONFIG_GCC_LTO),-flto) $(if $(CONFIG_GCC_GCOV),--coverage) 20 | AUTO_GEN_FILES+=$(if $(CONFIG_GCC_GCOV),$(OBJS:.o=.gcno) $(OBJS:.o=.gcda)) 21 | 22 | define get_lib_dir 23 | $(shell dirname $(shell $(CC) $(CFLAGS) -print-file-name=lib$1.a)) 24 | endef 25 | 26 | get_libgcc_dir=$(shell dirname $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)) 27 | get_libc_dir=$(call get_lib_dir,c) 28 | 29 | # Build commands 30 | compile=$(CC) $(CFLAGS) $(CFLAGS_$@) $(MK_CFLAGS_$@) -c -o $@ $< 31 | asm=$(AS) -o $@ $< 32 | calc_deps=$(CC) $(CFLAGS) -MM -MT $@ -MF $(@:.o=.d) $< 33 | include_deps=$(eval -include $(OBJS:.o=.d)) \ 34 | $(if $(LINKER_SCRIPT),$(eval -include $(LINKER_SCRIPT:.ld=.ld.d))) 35 | link=$(LD) $(LDFLAGS) $(if $(LINKER_SCRIPT),-T $(LINKER_SCRIPT)) -o $@ $(OBJS) $(LIBS) 36 | gen_image=$(OBJCOPY) -O binary $< $(IMAGE) 37 | 38 | # Targets 39 | TARGET_NAME:=tp 40 | IMAGE_NAME:=tp.bin 41 | 42 | # Rules 43 | $(BUILD)/%.ld : %.ld.S 44 | @echo GEN $@ 45 | $(Q)$(CPP) -MM -MT $@ -MF $(@:.ld=.ld.d) -I. -P $< $@ 46 | $(Q)$(CPP) -I. -P $< $@ 47 | -------------------------------------------------------------------------------- /scripts/header.mk: -------------------------------------------------------------------------------- 1 | MK_SUBDIRS:= 2 | MK_INCLUDES:= 3 | MK_OBJS:= 4 | MK_LINKS:= 5 | MK_JSAPIS:= 6 | MK_BUILTIN_FS_INTERNAL_FILES:= 7 | MK_ADDITIONAL_INCLUDE_PATHS:= 8 | MK_ADDITIONAL_INCLUDES:= 9 | $(shell mkdir -p $(BUILD)/$(d)) 10 | -------------------------------------------------------------------------------- /scripts/kconfig/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Generated files 3 | # 4 | config* 5 | *.lex.c 6 | *.tab.c 7 | *.tab.h 8 | zconf.hash.c 9 | *.moc 10 | gconf.glade.h 11 | *.pot 12 | *.mo 13 | 14 | # 15 | # configuration programs 16 | # 17 | conf 18 | mconf 19 | nconf 20 | qconf 21 | gconf 22 | kxgettext 23 | -------------------------------------------------------------------------------- /scripts/kconfig/POTFILES.in: -------------------------------------------------------------------------------- 1 | scripts/kconfig/lxdialog/checklist.c 2 | scripts/kconfig/lxdialog/inputbox.c 3 | scripts/kconfig/lxdialog/menubox.c 4 | scripts/kconfig/lxdialog/textbox.c 5 | scripts/kconfig/lxdialog/util.c 6 | scripts/kconfig/lxdialog/yesno.c 7 | scripts/kconfig/mconf.c 8 | scripts/kconfig/conf.c 9 | scripts/kconfig/confdata.c 10 | scripts/kconfig/gconf.c 11 | scripts/kconfig/gconf.glade.h 12 | scripts/kconfig/qconf.cc 13 | -------------------------------------------------------------------------------- /scripts/kconfig/check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Needed for systems without gettext 3 | $* -x c -o /dev/null - > /dev/null 2>&1 << EOF 4 | #include 5 | int main() 6 | { 7 | gettext(""); 8 | return 0; 9 | } 10 | EOF 11 | if [ ! "$?" -eq "0" ]; then 12 | echo -DKBUILD_NO_NLS; 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /scripts/kconfig/lxdialog/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Generated files 3 | # 4 | lxdialog 5 | -------------------------------------------------------------------------------- /scripts/kconfig/lxdialog/BIG.FAT.WARNING: -------------------------------------------------------------------------------- 1 | This is NOT the official version of dialog. This version has been 2 | significantly modified from the original. It is for use by the Linux 3 | kernel configuration script. Please do not bother Savio Lam with 4 | questions about this program. 5 | -------------------------------------------------------------------------------- /scripts/kconfig/zconf.gperf: -------------------------------------------------------------------------------- 1 | %language=ANSI-C 2 | %define hash-function-name kconf_id_hash 3 | %define lookup-function-name kconf_id_lookup 4 | %define string-pool-name kconf_id_strings 5 | %compare-strncmp 6 | %enum 7 | %pic 8 | %struct-type 9 | 10 | struct kconf_id; 11 | 12 | static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); 13 | 14 | %% 15 | mainmenu, T_MAINMENU, TF_COMMAND 16 | menu, T_MENU, TF_COMMAND 17 | endmenu, T_ENDMENU, TF_COMMAND 18 | source, T_SOURCE, TF_COMMAND 19 | choice, T_CHOICE, TF_COMMAND 20 | endchoice, T_ENDCHOICE, TF_COMMAND 21 | comment, T_COMMENT, TF_COMMAND 22 | config, T_CONFIG, TF_COMMAND 23 | menuconfig, T_MENUCONFIG, TF_COMMAND 24 | help, T_HELP, TF_COMMAND 25 | if, T_IF, TF_COMMAND|TF_PARAM 26 | endif, T_ENDIF, TF_COMMAND 27 | depends, T_DEPENDS, TF_COMMAND 28 | optional, T_OPTIONAL, TF_COMMAND 29 | default, T_DEFAULT, TF_COMMAND, S_UNKNOWN 30 | prompt, T_PROMPT, TF_COMMAND 31 | tristate, T_TYPE, TF_COMMAND, S_TRISTATE 32 | def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE 33 | bool, T_TYPE, TF_COMMAND, S_BOOLEAN 34 | boolean, T_TYPE, TF_COMMAND, S_BOOLEAN 35 | def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN 36 | int, T_TYPE, TF_COMMAND, S_INT 37 | hex, T_TYPE, TF_COMMAND, S_HEX 38 | string, T_TYPE, TF_COMMAND, S_STRING 39 | select, T_SELECT, TF_COMMAND 40 | range, T_RANGE, TF_COMMAND 41 | visible, T_VISIBLE, TF_COMMAND 42 | option, T_OPTION, TF_COMMAND 43 | on, T_ON, TF_PARAM 44 | modules, T_OPT_MODULES, TF_OPTION 45 | defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION 46 | env, T_OPT_ENV, TF_OPTION 47 | %% 48 | -------------------------------------------------------------------------------- /scripts/release_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $# != 3 ]] ; then 4 | echo "Usage: $0 "; 5 | exit 1; 6 | fi 7 | 8 | where="$1" 9 | last="$2" 10 | new="$3" 11 | 12 | binpath=$where/tinkerpal-v$new 13 | 14 | mkdir -p $binpath 15 | 16 | git shortlog --no-merges v$last..v$new > $binpath/ShortLog 17 | git diff --stat --summary -M v$last..v$new > $binpath/diffstat-v$new 18 | git archive --prefix=tinkerpal-$new/ v$new | gzip -9 > $binpath/tinkerpal-v$new-src.tgz 19 | 20 | function build() 21 | { 22 | target=$1; 23 | binfile_suffix=$2 24 | ./scripts/build_dist.sh $target $binpath $new $binfile_suffix 25 | } 26 | 27 | build lm4f120xl .bin 28 | build lm3s6965 .bin 29 | build lm3s6918 .bin 30 | build tm4c123g .bin 31 | build tm4c1294 .bin 32 | build stm32f3discovery .bin 33 | build stm32f3discovery .bin 34 | build stm32f429idiscovery .bin 35 | build stm32f4discovery .bin 36 | build frdm_kl25z .bin 37 | build unix_sim 38 | 39 | zip $binpath.zip $binpath/*; 40 | rm -rf $binpath; 41 | -------------------------------------------------------------------------------- /scripts/text_to_c.mk: -------------------------------------------------------------------------------- 1 | # text_to_c - generates a "c" string file from any file and adds it to the 2 | # build targets. 3 | # 4 | # Usage $(eval $(call text_to_c,$1,$2,$3)) 5 | # 6 | # $1 - target 7 | # $2 - source 8 | # $3 - variable name 9 | 10 | define text_to_c 11 | 12 | AUTO_GEN_FILES+=$1 13 | MK_OBJS+=$(notdir $(1:%.c=%.o)) 14 | 15 | $1:: $2 scripts/text_to_c_str.sed 16 | @echo GEN $$@ 17 | $$(Q)echo "#include \"util/tstr.h\"" > $1 18 | $$(Q)echo -n "char *$3 = " >> $1 19 | $$(Q)cpp -P $2 | sed -f scripts/text_to_c_str.sed >> $1 20 | $$(Q)echo ";" >> $1 21 | 22 | endef 23 | -------------------------------------------------------------------------------- /scripts/text_to_c_str.sed: -------------------------------------------------------------------------------- 1 | # sed script to convert a text file to a C string 2 | 3 | s/\\/\\\\/g # escapes backslashes 4 | s/"/\\"/g # escapes quotes 5 | s/ //g # converts tabs to nothing 6 | s/^/"/ # adds quotation mark to the beginning of a line 7 | s/$/\\n"/ # adds \n and a quotation mark to the end of a line 8 | -------------------------------------------------------------------------------- /scripts/ti_ccs5.mk: -------------------------------------------------------------------------------- 1 | $(info ==== Using TI CCS5 environment ====) 2 | TI_CCS5?=$(CONFIG_TI_CCS5_DIR:"%"=%) 3 | 4 | CFLAGS+=--preinclude $(BUILD)/autoconf.h 5 | CFLAGS+=-O2 -g --gcc --define=ccs="ccs" --diag_warning=225 \ 6 | --display_error_number --gen_func_subsections=on \ 7 | --preproc_with_compile 8 | 9 | INC+=--include_path=./ --include_path=$(BUILD) \ 10 | --include_path="$(TI_COMPILER)/include" \ 11 | $(addprefix --preinclude,$(ADDITIONAL_INCLUDES)) \ 12 | $(addprefix --include_path=,$(ADDITIONAL_INCLUDE_PATHS)) 13 | 14 | # These flags must come after the regular ldflags (specifically -z) 15 | ADDITIONAL_LDFLAGS=-O2 -g --gcc --define=ccs="ccs" --diag_warning=225 \ 16 | --display_error_number --gen_func_subsections=on -z \ 17 | -m"$(BUILD)/tp.map" -i"$(TI_COMPILER)/lib" -i"$(TI_COMPILER)/include" \ 18 | --reread_libs --warn_sections --display_error_number --rom_model 19 | 20 | # Build commands 21 | compile=$(CC) $(CFLAGS) $(MK_CFLAGS_$@) $(INC) --output_file $@ $< 22 | link=$(CC) $(LDFLAGS) $(ADDITIONAL_LDFLAGS) -i=$(BUILD) --output_file $@ $(OBJS) $(LIBS) $(LINKER_SCRIPT) 23 | gen_image= 24 | 25 | # Dependencies - alas, no automatic header dependency generation yet, 26 | # have all objs rely on all headers 27 | calc_deps= 28 | include_deps=$(eval $(OBJS) : $(shell find . -name "*.h")) 29 | 30 | # Targets 31 | TARGET_NAME:=tp.out 32 | IMAGE_NAME:=tp.bin 33 | -------------------------------------------------------------------------------- /tests/arguments_test.js: -------------------------------------------------------------------------------- 1 | function k() { 2 | debug.assert(arguments.length, 4); 3 | debug.assert(arguments[0], 1); 4 | debug.assert(arguments[1], 2); 5 | debug.assert(arguments[2], 3); 6 | debug.assert(arguments[3], 4); 7 | console.log(arguments); 8 | } 9 | 10 | k(1, 2, 3, 4); 11 | 12 | function p() { 13 | k(1, 2, 3, 4); 14 | } 15 | 16 | p(2, 3, 4, 5); 17 | 18 | b = 3; 19 | function f(a, b, c) { debug.assert(b, undefined); } 20 | f(1); 21 | function k() { debug.assert(arguments[2], undefined); } 22 | k(); 23 | function k() { debug.assert(arguments["kuku"], undefined); } 24 | k(); 25 | -------------------------------------------------------------------------------- /tests/builtins_test.js: -------------------------------------------------------------------------------- 1 | debug.assert(1, 1); 2 | -------------------------------------------------------------------------------- /tests/cast_test.js: -------------------------------------------------------------------------------- 1 | debug.assert(3=="3",true); 2 | debug.assert(3=="4",false); 3 | debug.assert("3"==3,true); 4 | debug.assert("13"==3,false); 5 | debug.assert("13"!=3,true); 6 | debug.assert(0 == false, true); 7 | debug.assert(0 == true, false); 8 | debug.assert(1 == true, true); 9 | debug.assert(1 == false, false); 10 | debug.assert(1 != false, true); 11 | -------------------------------------------------------------------------------- /tests/closure_test.js: -------------------------------------------------------------------------------- 1 | var basic_closure = function() { 2 | var count = 0; 3 | return function() { 4 | return ++count; 5 | }; 6 | }; 7 | var inc = basic_closure(); 8 | debug.assert(inc(), 1); 9 | debug.assert(inc(), 2); 10 | debug.assert(inc(), 3); 11 | debug.assert(inc(), 4); 12 | 13 | var limited_scoping = function() { 14 | return function() { 15 | var x; 16 | 17 | x = 1; 18 | 19 | return x; 20 | }; 21 | }; 22 | 23 | var t = limited_scoping(); 24 | debug.assert(t(), 1); 25 | debug.assert(t(), 1); 26 | 27 | var sum_factory = function() { 28 | return function(x, y) { 29 | return x + y; 30 | }; 31 | }; 32 | 33 | var sum = sum_factory(); 34 | debug.assert(sum(1, 2), 3); 35 | 36 | function P(v) { this.v = v; }; 37 | P.prototype.get = function() { return this.v; }; 38 | var a = new P(1); 39 | var b = new P(2); 40 | debug.assert(a.get(), 1); 41 | debug.assert(b.get(), 2); 42 | b.get = function() { return 3; }; 43 | debug.assert(a.get(), 1); 44 | debug.assert(b.get(), 3); 45 | -------------------------------------------------------------------------------- /tests/emit_test.js: -------------------------------------------------------------------------------- 1 | var a = {}; 2 | 3 | /* Test single listener */ 4 | var good = 0; 5 | a.on('test1', function() { good++; }); 6 | a.emit('test1'); 7 | debug.assert(good, 1); 8 | a.removeAllListeners('test1'); 9 | a.emit('test1'); 10 | debug.assert(good, 1); 11 | 12 | console.log('!!'); 13 | /* Test multiple listeners */ 14 | var good = 0, good2 = 0; 15 | a.on('test2', function() { good++; }); 16 | a.on('test2', function() { good2+=10; }); 17 | a.emit('test2'); 18 | debug.assert(good, 1); 19 | debug.assert(good2, 10); 20 | a.removeAllListeners('test2'); 21 | a.emit('test2'); 22 | debug.assert(good, 1); 23 | debug.assert(good2, 10); 24 | a.on('test2', function() { good2+=10; }, 3); 25 | 26 | /* Object.listeners */ 27 | function f() { } 28 | a.on('dummy', f); 29 | debug.assert(a.listeners('dummy')[0], f); 30 | debug.assert(a.listeners('no_such_event'), undefined); 31 | a.removeAllListeners('dummy'); 32 | 33 | good = 0; 34 | a.on('add', function(x) { good += x; }); 35 | a.emit('add', 100); 36 | debug.assert(good, 100); 37 | a.removeAllListeners(); 38 | a.emit('add', 1000); 39 | debug.assert(good, 100); 40 | a.removeAllListeners(); 41 | good = 0; 42 | a.on('add', function(x) { good += x; }); 43 | a.emit('add', 1000); 44 | debug.assert(good, 1000); 45 | 46 | /* Remove non-existent listener */ 47 | a.removeAllListeners('kuku'); 48 | debug.assert_exception(function() { a.on('add', "should_be_function"); }); 49 | debug.assert_exception(function() { a.emit(); }); 50 | debug.assert_exception(function() { a.listeners(); }); 51 | -------------------------------------------------------------------------------- /tests/eval_test.js: -------------------------------------------------------------------------------- 1 | var j; 2 | 3 | j = eval("1 + 2"); 4 | debug.assert(j, 3); 5 | 6 | var k; 7 | 8 | k = eval("j = { foo : 43 }"); 9 | debug.assert(k.foo, 43); 10 | 11 | var l = eval("1" + "+" + "1"); 12 | debug.assert(l, 2); 13 | 14 | var m = eval(1); 15 | debug.assert(m, 1); 16 | 17 | debug.assert(eval(), undefined); 18 | -------------------------------------------------------------------------------- /tests/file_test.js: -------------------------------------------------------------------------------- 1 | var s = 'hello world! - uptime: ' + getTime(); 2 | console.log('Test String : ' + s); 3 | fs.writeFileSync('Local/test.txt', s); 4 | var s2 = fs.readFileSync('Local/test.txt'); 5 | debug.assert(s, s2); 6 | fs.writeFileSync('FAT/test.txt', s); 7 | var s2 = fs.readFileSync('FAT/test.txt'); 8 | 9 | var dirs = fs.readdirSync('.'); 10 | console.log(dirs); 11 | debug.assert(dirs[0], 'FAT'); 12 | var files = fs.readdirSync('FAT/'); 13 | console.log(files); 14 | debug.assert(files[0], 'TEST.TXT'); 15 | 16 | var dirs = fs.readdirSync('/'); 17 | debug.assert(dirs[0], 'FAT'); 18 | 19 | var builtin_files = fs.readdirSync('Builtin'); 20 | debug.assert(builtin_files[0], 'assert'); 21 | 22 | /* Builtin fs doesn't allow subfolders */ 23 | debug.assert_exception(function() { console.log(fs.readdirSync('Builtin/kuku/ku')); }); 24 | 25 | /* Test file handling exceptions */ 26 | debug.assert_exception(function() { fs.readdirSync('.', "invalid arg"); }); 27 | debug.assert_exception(function() { fs.readFileSync('FAT/test.txt', "invalid arg"); }); 28 | debug.assert_exception(function() { fs.readFileSync('FAT/no_such_file'); }); 29 | debug.assert_exception(function() { fs.readdirSync('FAT/no_such_path/no_such_file'); }); 30 | debug.assert_exception(function() { fs.writeFileSync('Local/test.txt', s, 'invalid arg'); }); 31 | debug.assert_exception(function() { fs.readFileSync('no_such_fs/no_such_file'); }); 32 | debug.assert_exception(function() { fs.writeFileSync('no_such_fs/test.txt', s); }); 33 | debug.assert_exception(function() { fs.readdirSync('no_such_fs/'); }); 34 | debug.assert_exception(function() { fs.readdirSync('no_such_fs/'); }); 35 | -------------------------------------------------------------------------------- /tests/for_test.js: -------------------------------------------------------------------------------- 1 | var i; 2 | 3 | for (i = 0; i < 20; i+=2) 4 | console.log(i); 5 | debug.assert(i, 20); 6 | 7 | for (i = 0; i < 20; i++) 8 | { 9 | if (i == 5) 10 | break; 11 | } 12 | 13 | debug.assert(i, 5); 14 | 15 | var x, y, z = 0; 16 | 17 | for (x = 0; x < 10; x++) 18 | { 19 | for (y = 0; y < 10; y++) 20 | { 21 | if (y == 5) 22 | break; 23 | 24 | z++; 25 | } 26 | } 27 | 28 | debug.assert(z, 50); 29 | 30 | var i, a = [4, 5, 6], sum = 0; 31 | for (i in a) 32 | sum += a[i]; 33 | debug.assert(sum, 15); 34 | for (i in a) 35 | sum += a[i]; 36 | debug.assert(sum, 30); 37 | for (i in a) 38 | { 39 | if (i == 1) 40 | break; 41 | sum += a[i]; 42 | } 43 | debug.assert(sum, 34); 44 | 45 | var a = { a : 1, b : 1 }; 46 | a.prototype = { c : 2 }; 47 | var b = []; 48 | for (i in a) 49 | b.push(i); 50 | 51 | debug.assert(b[2], "c"); 52 | 53 | var i, j; 54 | 55 | for (i = 0; i < 10; i++) 56 | for (j = 0; j < 10; j++) 57 | console.log("(" + i + ", " + j + ")"); 58 | 59 | var count = 5; 60 | for (;--count;); 61 | debug.assert(count, 0); 62 | var count = 5; 63 | for (;;) if (count-- == 3) break; 64 | debug.assert(count, 2); 65 | debug.assert_exception(function() { 66 | for (var 3 = 4; ;) {} 67 | }); 68 | debug.assert_exception(function() { 69 | for (3 = 4; ;) {} 70 | }); 71 | 72 | var a = [ 0, 1, 2 ], b; 73 | function f() { return a; } 74 | for (b in f()) 75 | debug.assert(a[b], b); 76 | 77 | var a = [[ 0, 1, 2 ]], b; 78 | for (c in a[0]) 79 | debug.assert(a[0][c], c); 80 | -------------------------------------------------------------------------------- /tests/fp_test.js: -------------------------------------------------------------------------------- 1 | debug.assert(345,345); 2 | debug.assert(34.5*10,345); 3 | debug.assert(3.45*100,345); 4 | debug.assert(3.45e2,345); 5 | debug.assert(0531,345); 6 | debug.assert(3.456e3,3456); 7 | debug.assert(3.4567e4,34567); 8 | debug.assert(3.45678e5,345678); 9 | debug.assert(3.456789e6,3456789); 10 | debug.assert(3.4567891e7,34567891); 11 | debug.assert(0xdeadbeaf,3735928495); 12 | debug.assert_exception(function() { var x = 3.45e; }); 13 | debug.assert_exception(function() { var x = 3.45e2e3; }); 14 | -------------------------------------------------------------------------------- /tests/func_apply_test.js: -------------------------------------------------------------------------------- 1 | function sum(a, b) { return a+b; } 2 | console.log("==1=="); 3 | debug.assert(sum.apply(undefined, [1,2]), 3); 4 | function add_prop() { this.prop = 1; } 5 | var o = {}; 6 | add_prop.apply(o); 7 | console.log("==2=="); 8 | debug.assert(o.prop, 1); 9 | function this_sum(a, b) { this.sum = a + b; } 10 | this_sum.apply(o, [3, 5]); 11 | console.log("==3=="); 12 | debug.assert(o.sum, 8); 13 | /* Test non-array argsArray */ 14 | console.log("==4=="); 15 | debug.assert(sum.apply(undefined, "abc"), "ab"); 16 | debug.assert_exception(function() { sum.apply(); }); 17 | debug.assert_exception(function() { 18 | /* Test too many args */ 19 | sum.apply(undefined,[1,2,3,4,5,6,7,8,9,10,11,12,13,14]); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/func_bind_test.js: -------------------------------------------------------------------------------- 1 | function template() { return this.prop; } 2 | var t = template.bind({ prop : 1 }); 3 | debug.assert(t(), 1); 4 | var v = 1; 5 | function f() {return this.v; } 6 | var k = f.bind(); 7 | debug.assert(k(), v); 8 | -------------------------------------------------------------------------------- /tests/func_constructor_test.js: -------------------------------------------------------------------------------- 1 | var f = new Function(); 2 | f.prototype.bla = function() { return 1; }; 3 | debug.assert(f.bla(), 1); 4 | var g = new f(); 5 | debug.assert(g.bla(), 1); 6 | var two = new Function("return 1 + 1"); 7 | debug.assert(two(), 2); 8 | var echo = new Function("a", "return a"); 9 | debug.assert(echo(1), 1); 10 | debug.assert(echo("kuku"), "kuku"); 11 | var sum = new Function("a", "b", "return a+b"); 12 | debug.assert(sum(1, 2), 3); 13 | var sum = new Function("a, b", "return a+b"); 14 | debug.assert(sum(1, 2), 3); 15 | var sum = new Function("a, b", "c", "return a+b+c"); 16 | debug.assert(sum(1, 2, 3), 6); 17 | debug.assert_exception(function() { var f = new Function("a, b,", "c"); }); 18 | -------------------------------------------------------------------------------- /tests/gpio_test.js: -------------------------------------------------------------------------------- 1 | var i = 1, t=9000; 2 | 3 | while (t--) 4 | { 5 | digitalWrite(1, 1, i); 6 | } 7 | -------------------------------------------------------------------------------- /tests/leak_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | executable="../build.Linux/tp"; 4 | 5 | if [ $SKIP_TESTS ]; then 6 | exit 0; 7 | fi 8 | 9 | function lc() 10 | { 11 | echo "dummy data" | valgrind -v --leak-check=full --num-callers=50 --show-reachable=yes --track-origins=yes $executable $1 &> $1.lc; 12 | } 13 | 14 | if [ $UNIT_TESTS ]; then 15 | lc unit_test 16 | grep "ERROR SUMMARY" unit_test.lc; 17 | exit 0; 18 | fi 19 | 20 | list="closure_test.js while_test.js func_test.js exp_test.js object_test.js string_test.js prototype_test.js member_test.js for_test.js array_test.js fp_test.js self_ref.js eval_test.js func_constructor_test.js throw_test.js switch_test.js properties_test.js typed_array.js func_bind_test.js func_apply_test.js timer_test.js file_test.js arguments_test.js module_test.js emit_test.js serial_test.js math_test.js graphics_test.js"; 21 | 22 | if [[ -n $1 ]] ; then 23 | lc $1; 24 | exit; 25 | fi 26 | for l in $list; do 27 | echo "============================" 28 | lc $l; 29 | grep "ERROR SUMMARY" $l.lc; 30 | if [[ $? != 0 ]]; then 31 | echo "Test $l failed"; 32 | break; 33 | fi 34 | echo "Test $l completed successfully"; 35 | done 36 | 37 | -------------------------------------------------------------------------------- /tests/math_test.js: -------------------------------------------------------------------------------- 1 | /* Most of these checks pass fine, though comparing FPs is risky */ 2 | debug.assert(Math.sin(Math.Pi / 2), 1); 3 | c = Math.cos(Math.Pi / 2); 4 | debug.assert_cond(c > -0.005 && c < 0.005); 5 | debug.assert(Math.asin(1), Math.Pi / 2); 6 | debug.assert(Math.acos(1), 0); 7 | debug.assert(Math.tan(Math.Pi / 4), 1); 8 | debug.assert(Math.atan(0), 0); 9 | debug.assert(Math.sqrt(9), 3); 10 | debug.assert(Math.log(Math.E * Math.E), 2); 11 | debug.assert(Math.exp(2), Math.E * Math.E); 12 | debug.assert(Math.floor(2.4), 2); 13 | debug.assert(Math.ceil(2.4), 3); 14 | debug.assert(Math.round(2.4), 2); 15 | debug.assert(Math.round(2.6), 3); 16 | debug.assert(Math.abs(-2), 2); 17 | debug.assert(Math.atan2(1, 1), Math.Pi / 4); 18 | debug.assert(Math.pow(10, 2), 100); 19 | -------------------------------------------------------------------------------- /tests/member_test.js: -------------------------------------------------------------------------------- 1 | console.log("==== 1"); 2 | var test = { func : function() { return { bla : 50 }; } }; 3 | console.log("==== 2"); 4 | debug.assert(test.func().bla, 50); 5 | console.log("==== 3"); 6 | var test2 = { func : function() 7 | { 8 | return { blaf : function() { return { bla : 20 } } }; 9 | } 10 | }; 11 | console.log("==== 4"); 12 | debug.assert(test2.func().blaf().bla, 20); 13 | console.log("==== 5"); 14 | 15 | function recur() 16 | { 17 | return function() { return function() { return function() { return 1978; }; }; }; 18 | } 19 | console.log("==== 6"); 20 | 21 | debug.assert(recur()()()(), 1978); 22 | 23 | console.log("==== 7"); 24 | var obj = { prop1 : 50, func : function() { return 39; } }; 25 | console.log("==== 8"); 26 | debug.assert(obj["prop1"], 50); 27 | console.log("==== 9"); 28 | debug.assert(obj["func"](), 39); 29 | console.log("==== 10"); 30 | debug.assert(obj.func(), 39); 31 | console.log("==== 11"); 32 | debug.assert(obj["fu" + "nc"](), 39); 33 | console.log("==== 12"); 34 | var obj2 = { prop1 : 50, func : function() { return { gugu : function() { return 50; } }; } }; 35 | console.log("==== 13"); 36 | debug.assert(obj2["func"]()['gugu'](), 50); 37 | console.log("==== 14"); 38 | 39 | -------------------------------------------------------------------------------- /tests/misc_test.js: -------------------------------------------------------------------------------- 1 | if (false) 2 | debug.assert(1, 0); 3 | else 4 | good = 1; 5 | 6 | debug.assert(good, 1); 7 | 8 | good = 0; 9 | 10 | if (false) 11 | debug.assert(1, 0); 12 | else if (1 == 0) 13 | debug.assert(1, 0); 14 | else 15 | good = 1; 16 | 17 | debug.assert(good, 1); 18 | 19 | good = 0; 20 | 21 | if (false) 22 | debug.assert(1, 0); 23 | else if (1 == 1) 24 | good = 1; 25 | else 26 | debug.assert(1, 0); 27 | 28 | debug.assert(good, 1); 29 | 30 | good = 0; 31 | 32 | if (true) 33 | good = 1; 34 | else if (1 == 1) 35 | debug.assert(1, 0); 36 | else 37 | debug.assert(1, 0); 38 | 39 | debug.assert(good, 1); 40 | 41 | /* Run various API functions */ 42 | console.log('--------------'); 43 | meminfo(); 44 | console.log('--------------'); 45 | describe(describe); 46 | describe(3); 47 | console.log('--------------'); 48 | debug.dump_env(); 49 | console.log('--------------'); 50 | debug.assert_exception(function() { compile(function() { }); }); 51 | console.log(-1.1); 52 | 53 | debug.assert_exception(function() { var x = 3 5; }); 54 | debug.assert_exception(function() { debug.assert_cond(true, 1); }); 55 | debug.assert_exception(function() { debug.assert_exception(true); }); 56 | debug.assert_exception(function() { debug.dump_env(3); }); 57 | debug.assert_exception(function() { describe(1, 3) }); 58 | debug.assert_exception(function() { compile(1, 3) }); 59 | debug.assert_exception(function() { var x = 3, 3; }); 60 | good = 0; 61 | try { 62 | console.log(arguments[0]); 63 | } catch (exp) { 64 | console.log(exp); 65 | good = 1; 66 | } 67 | debug.assert(good, 1); 68 | -------------------------------------------------------------------------------- /tests/module_test.js: -------------------------------------------------------------------------------- 1 | /* Test module loading */ 2 | as = require('assert'); 3 | as2 = require('assert'); 4 | debug.assert(as, as); 5 | 6 | 7 | debug.assert_exception(function() { doesnt_exist = require('assert2'); }); 8 | 9 | debug.assert_exception(function() { invalid_args = require('assert', "invalid_arg"); }); 10 | -------------------------------------------------------------------------------- /tests/pong.js: -------------------------------------------------------------------------------- 1 | console.log("Pong"); 2 | 3 | digitalWrite(GPIO_PB2, 1); 4 | var l = new PCD8544(); 5 | var l2 = new SSD1306(); 6 | var g = new Graphics(l); 7 | var g2 = new Graphics(l2); 8 | 9 | function ball(gr, x, y, c) { 10 | gr.circleDraw(x, y, 4, c); 11 | } 12 | 13 | function pong(canvas, gr, maxx, maxy, x, y) { 14 | var dx = 1, dy = 1; 15 | var update = compile(function() { 16 | ball(gr, x, y, 0); 17 | x = x + dx; 18 | y = y + dy; 19 | ball(gr, x, y, 1); 20 | canvas.flip(); 21 | }); 22 | return function() { 23 | update(); 24 | if (x < 5 || x > maxx) dx *= -1; 25 | if (y < 5 || y > maxy) dy *= -1; 26 | } 27 | } 28 | 29 | var ball1_step = pong(l, g, 79, 43, 5, 5); 30 | var ball2_step = pong(l2, g2, 123, 59, 5, 5); 31 | 32 | function step() { 33 | ball1_step(); 34 | ball2_step(); 35 | } 36 | 37 | l2.fill(0); 38 | console.log(compile(step)); 39 | setInterval(step, 10); 40 | -------------------------------------------------------------------------------- /tests/properties_test.js: -------------------------------------------------------------------------------- 1 | a = [1,2,3]; 2 | var a = [1,2,3,4]; 3 | /* Overriding a variable must not leak */ 4 | -------------------------------------------------------------------------------- /tests/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOST_OS=`uname`; 4 | 5 | executable="../build.$HOST_OS/tp"; 6 | 7 | if [ $SKIP_TESTS ]; then 8 | exit 0; 9 | fi 10 | 11 | if [ $UNIT_TESTS ]; then 12 | $executable; 13 | rc=$?; 14 | exit $rc; 15 | fi 16 | 17 | /sbin/ifconfig 18 | 19 | list="closure_test.js while_test.js func_test.js exp_test.js object_test.js string_test.js prototype_test.js member_test.js for_test.js array_test.js fp_test.js self_ref.js eval_test.js func_constructor_test.js throw_test.js switch_test.js properties_test.js typed_array.js func_bind_test.js func_apply_test.js timer_test.js file_test.js arguments_test.js module_test.js netif_test.js misc_test.js emit_test.js serial_test.js math_test.js graphics_test.js"; 20 | 21 | for l in $list; do 22 | echo "============================" 23 | # inject dummy data for input requiring tests (e.g. serial test) 24 | echo "dummy data" | $executable $l; 25 | if [[ $? != 0 ]]; then 26 | echo "Test $l failed"; 27 | exit 1; 28 | fi 29 | echo "Test $l completed successfully"; 30 | done 31 | -------------------------------------------------------------------------------- /tests/self_ref.js: -------------------------------------------------------------------------------- 1 | function kuku() 2 | { 3 | var ku = function() {}; 4 | } 5 | 6 | kuku(); 7 | -------------------------------------------------------------------------------- /tests/serial_test.js: -------------------------------------------------------------------------------- 1 | var s = new Serial(UART0); 2 | 3 | s.print('Hello!'); 4 | s.write('Hello!'); 5 | s.write(65); 6 | s.write(['hello1\n','hello2\n','hello3\n']); 7 | 8 | debug.assert_exception(function() { console.set(); }); 9 | debug.assert_exception(function() { console.log(); }); 10 | 11 | console.set(s); 12 | s.onData(function(e) { s.onData(); console.log(e); }); 13 | 14 | var s2 = new Serial(UART3); 15 | s2.print('kuku!'); 16 | -------------------------------------------------------------------------------- /tests/stack_analyze.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | valgrind --tool=massif --stacks=yes --massif-out-file=test.ms --time-unit=B ./js $1 3 | ms_print test.ms 4 | -------------------------------------------------------------------------------- /tests/switch_test.js: -------------------------------------------------------------------------------- 1 | var i = 1, val; 2 | 3 | switch (i) 4 | { 5 | } 6 | 7 | switch (i) 8 | { 9 | case 1: 10 | val = 1; 11 | case 2: 12 | val = 2; 13 | break; 14 | case 3: 15 | debug.assert(3 == 0); 16 | break; 17 | case 4: 18 | debug.assert(4 == 0); 19 | break; 20 | } 21 | 22 | debug.assert(val, 2); 23 | 24 | var b = i; 25 | 26 | switch (i) 27 | { 28 | case b: 29 | val = 17; 30 | break; 31 | case 3: 32 | debug.assert(3 == 0); 33 | break; 34 | default: 35 | debug.assert(1 == 0); 36 | break; 37 | } 38 | 39 | debug.assert(val, 17); 40 | 41 | switch (i) 42 | { 43 | case 3: 44 | debug.assert(3 == 0); 45 | break; 46 | default: 47 | val = 55; 48 | break; 49 | } 50 | 51 | debug.assert(val, 55); 52 | 53 | function do_test() 54 | { 55 | switch(1) 56 | { 57 | case 2: 58 | return 1; 59 | case 1: 60 | return 2; 61 | } 62 | } 63 | 64 | debug.assert(do_test(), 2); 65 | 66 | function fallthrough_to_default() 67 | { 68 | switch (1) 69 | { 70 | case 1: 71 | val = 3; 72 | default: 73 | return 4; 74 | } 75 | } 76 | 77 | debug.assert(fallthrough_to_default(), 4); 78 | debug.assert(val, 3); 79 | debug.assert_exception(function() { 80 | switch (no_func()) 81 | { 82 | } 83 | }); 84 | debug.assert_exception(function() { switch(1); }); 85 | debug.assert_exception(function() { switch(1) { case 3=1: } }); 86 | debug.assert_exception(function() { switch(1) { 1: } }); 87 | debug.assert_exception(function() { switch(1) { case 1 console.log(11); } }); 88 | -------------------------------------------------------------------------------- /tests/throw_test.js: -------------------------------------------------------------------------------- 1 | var x = 0; 2 | 3 | function bla() 4 | { 5 | throw 1; 6 | } 7 | 8 | function kuku() 9 | { 10 | console.log(1); 11 | bla(); 12 | debug.assert(2, 0); 13 | } 14 | 15 | function dudu() 16 | { 17 | console.log(2); 18 | kuku(); 19 | debug.assert(1, 0); 20 | } 21 | 22 | function pupu() 23 | { 24 | console.log(3); 25 | try 26 | { 27 | console.log(4); 28 | dudu(); 29 | debug.assert(3, 0); 30 | } 31 | catch (should_be_one) 32 | { 33 | var x = 1 + 1; 34 | console.log("kuku"); 35 | debug.assert(should_be_one, 1); 36 | } 37 | } 38 | 39 | function susu() 40 | { 41 | console.log(6); 42 | pupu(); 43 | x = 1; 44 | } 45 | 46 | susu(); 47 | debug.assert(x, 1); 48 | 49 | debug.assert_exception(function() { no_such_function(); }); 50 | debug.assert_exception(function() { var num = 1; num(); }); 51 | debug.assert_exception(function() { 1 + 2 * no_such_function(); }); 52 | debug.assert_exception(function() { debug.assert(1, 2, 3); }); 53 | debug.assert_exception(function() { (debug.assert(1, 2, 3)); }); 54 | debug.assert_exception(function() { (debug.assert(1, 2, 3);) }); 55 | -------------------------------------------------------------------------------- /tests/timer_test.js: -------------------------------------------------------------------------------- 1 | var did = 0; 2 | setTimeout(function() { console.log("Called"); did=1; }, 300); 3 | setTimeout(function() { debug.assert(did, 1); }, 600); 4 | 5 | var count = 0; 6 | var tid = setInterval(function() { if (++count == 3) clearInterval(tid); }, 300); 7 | setTimeout(function() { debug.assert(count, 3); }, 1200); 8 | var count2 = 0; 9 | var tid2 = setInterval(function() { if (++count2 == 3) return -1; }, 300); 10 | setTimeout(function() { debug.assert(count2, 3); }, 1200); 11 | setTimeout(function() { }, 1600); 12 | setTimeout(function() {clearTimeout(); }, 1500); 13 | 14 | debug.assert_exception(function() { setTimeout(); }); 15 | debug.assert_exception(function() { setInterval(function() {}, 5000, 1); }); 16 | debug.assert_exception(function() { clearInterval(1, 2); }); 17 | -------------------------------------------------------------------------------- /tests/tp_fat_fs.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebirger/tinkerpal/c25c8a8f45a6d40cd83cab0b8a0a94eac681471b/tests/tp_fat_fs.bin -------------------------------------------------------------------------------- /tests/while_test.js: -------------------------------------------------------------------------------- 1 | var x, y; 2 | function bla() 3 | { 4 | x = 3; 5 | while (--x) 6 | { 7 | if (x > 1) 8 | continue; 9 | 10 | return 5; 11 | } 12 | debug.assert(1,0); 13 | } 14 | function main() 15 | { 16 | x = 5; 17 | while (x--); 18 | debug.assert(x, -1); 19 | 20 | x = 5; 21 | while (--x); 22 | debug.assert(x, 0); 23 | x = 3; 24 | while (x) 25 | x--; 26 | debug.assert(x, 0); 27 | 28 | y = 5; 29 | x = 7; 30 | while (--x) 31 | { 32 | if (x > 3) 33 | continue; 34 | y--; 35 | } 36 | debug.assert(x, 0); 37 | debug.assert(y, 2); 38 | debug.assert(bla(),5); 39 | x = 5; 40 | while (--x) 41 | { 42 | if (x == 3) 43 | { 44 | break; 45 | } 46 | } 47 | debug.assert(x, 3); 48 | } 49 | 50 | var i = 10; 51 | 52 | do console.log(i); while(--i); 53 | 54 | debug.assert(i, 0); 55 | 56 | var a = 0; 57 | do { a++; } while (a < 10); 58 | 59 | debug.assert(a, 10); 60 | 61 | var a = 0; 62 | do 63 | { 64 | a++; 65 | if (a > 5) 66 | break; 67 | } while (a < 10); 68 | 69 | debug.assert(a, 6); 70 | 71 | var a = 0, c = 0; 72 | do 73 | { 74 | a++; 75 | if (a < 5) 76 | continue; 77 | c++; 78 | } while (a < 10); 79 | 80 | debug.assert(c, 6); 81 | 82 | main(); 83 | 84 | debug.assert_exception(function() { 85 | do { } while (no_such_func()); 86 | }); 87 | debug.assert_exception(function() { 88 | while (no_such_func()) {} 89 | }); 90 | -------------------------------------------------------------------------------- /usb/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig USB 2 | bool "USB Support" 3 | default y 4 | depends on PLAT_HAS_USB 5 | 6 | if USB 7 | 8 | config USB_DEVICE 9 | bool "USB Device Support" 10 | default y 11 | 12 | config USB_CDC_ACM 13 | bool "USB CDC ACM Device Support" 14 | depends on USB_DEVICE 15 | default y 16 | 17 | config USB_DEVICE_QUIRK_SET_ADDR_IMM 18 | bool 19 | 20 | endif 21 | -------------------------------------------------------------------------------- /usb/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=$(if $(CONFIG_USB_DEVICE),usbd_core.o) 2 | MK_OBJS+=$(if $(CONFIG_USB_CDC_ACM),cdc_acm.o) 3 | -------------------------------------------------------------------------------- /usb/usbd.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Eyal Birger 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * The name of the author may not be used to endorse or promote products 12 | * derived from this software without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef __USBD_H__ 26 | #define __USBD_H__ 27 | 28 | static inline void usbd_uninit(void) {} 29 | 30 | #ifdef CONFIG_USB_DEVICE 31 | 32 | void usbd_init(void); 33 | 34 | #else 35 | 36 | static inline void usbd_init(void) {} 37 | 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /util/Makefile: -------------------------------------------------------------------------------- 1 | MK_OBJS+=debug.o tstr.o tstr_list.o tnum.o tprintf.o event.o 2 | MK_OBJS+=$(if $(CONFIG_CLI),cli.o history.o) 3 | --------------------------------------------------------------------------------