screen /dev/tty.usbserial-A400gw05 115200 >> output.txt //Ctrl-A then Ctrl-K then y and <Enter> exits
Turn on warnings for arduino! It'll catch dumb compiler stuff like this:
unsigned long a = 500 * 1000; // ~30000 unsigned long a = (unsigned long) 500 * 1000; // 500000
Also default value for int is 2^16
Name | Board | Programmer | Notes |
---|---|---|---|
Pro Trinket | Pro Trinket 5V 16MHz | USBtinyISP | Need to install Adafruit driver for Windows |
Arduino Mini Clone (CH340) | Arduino Duemolinovae | AVRISP mkII | Need to install CH340 drivers for Windows |
Wemos D1 Mini | LOLIN WEMOS D1 R2 & Mini | AVRISP mkII | I think CH340 drivers too |
Cheap arduino clones at Banggood. Probably don't want an attiny as there's not a lot of flash/ram space. .50 more and a little more real estate to use something more, 328p for example.
Don't need it right now as I have other similar boards available that I can use up. But for future projects…
Bought FTDI header. Cheap.
Cheap at banggood. Can get 3a input and buck/boost for dollars.
Lots of good tips in this flashlight led recharge li ion project video. Maybe need a fuse though
YouTube Link! https://www.youtube.com/watch?v=0CnhTuoTY2M
Also spot welder with old microwave, maybe batteries.
It might be helpful to have a simulator running your chip. For example, if you want to give funky inputs but don't have an extra scope lying around. Ehhh…most people want to test on the hardware itself.
> git clone https://github.com/spark/firmware > git checkout latest //(not develop) > cd firmware/user/applications/ firmware/user/applications> ln -s ~/Dropbox/eng/projects/homerot/spark/homerot/src/ homerot firmware/user/applications> cd ../../main firmware/main> sudo make clean all PLATFORM=core APP=homerot program-dfu
SYSTEM_MODE(MANUAL); bool WiFiEnabled = 0; void loop() { if (ConnectToWifiNow == 1 && WiFiEnabled == 0) { WiFi.connect(); WiFiEnabled = 1; } //Wait until WiFi is ready if (WiFi.ready() == 1) { //Do sync stuff DoSyncStuff(); //Then WiFi.disconnect(); WiFiEnabled = 0; } }
Spark.syncTime()
, you have to do Spark.connect() and Spark.process() as below.bool SparkConnect = 1; if (WiFi.ready() == 1 && SparkConnect == 0) { Spark.connect(); SparkConnect = 1; } if (WiFi.ready() == 1 && Spark.connected() && Time.now() < 1000000) { Spark.process(); //Spark.syncTime(); Serial.println("Syncing time"); } if (WiFi.ready() == 1 && Spark.connected() && Time.now() > 100000) { Spark.disconnect(); WiFi.disconnect(); WiFiConnect = 0; SparkConnect = 0; }
I am using a Bus Pirate for debugging because I have it lying around. Bus Pirate pinout,Spark core Pinout (make sure TDO (D4 on Core)is pulled up with 10K resistor!)
Additionally, if your wifi isn't working (optionally, you hear a high-pitched whining from the board), plug in your USB serial cable as you don't have enough power!. It provides the >200mA of current needed for the WiFi chip plus your normal serial connection.
Build your code using make (as normal), but add JTAG and debug flag support:
make clean //Erase your normal (non-debug) build USE_SWD_JTAG=y DEBUG_BUILD=y make //Rebuild with debug flags
Set some stuff for OpenOCD:
source [find interface/buspirate.cfg] #Set serial port buspirate_port /dev/ttyUSB0 # Not really used buspirate_vreg 0 #turn on voltage regulator buspirate_mode normal #or open-drain buspirate_pullup 1
# This is a SPARK-CORE board with a single STM32F103MD chip. source [find target/stm32f1x.cfg] # use hardware reset, connect under reset reset_config srst_only srst_nogate
Start up OpenOCD server
> sudo openocd -f mybuspirate.cfg -f sparkcore.cfg
Open up a Telnet connection to OpenOCD to reset the chip if needed. (soft_reset_halt seems to work better than reset halt)
> telnet localhost 4444 telnet> soft_reset_halt
To run, do arm-none-eabi-gdb -x jtag.gdb -tui
, then <Ctrl>+x 2
which enables assembly and code view mode. <Ctrl>+x o
switches the views. More info here
target remote localhost:3333 file core-firmware.elf set remotetimeout 2000
<project-dir> > sudo ../sparky make
To distinguish between the normal spark commands and Spark-Util commands, I've made a local executable of spark-util and called it sparky
Follow Spark-Util instructions for doing multiple projects at once. However, I think you need to reset in between changing projects, which wipes out your build.mk file, so be sure to have a backup.
Added -std=gnu++11
to CFLAGS +=
in spark/core-firmware/build/Makefile
, now static asserts work!
Can't put header and implementation in the same file for some reason. It's saying there's multiple definitions :/
Include a separate library inside of your C++ and H files? It still doesn't work… >.<
Not sure how much easier hardware method using LUFA is compared to software V-USB. Will be finding out soon.