Previous Part:
Hacking "ESP8266 Black Board T5" Part 1 - Blinky on Keil
Lets now move to SDCC, because SDCC is free and the free version of Keil has limitations. We will also move away from Windows to Ubuntu 64 bit
Installing SDCC on your Ubuntu PC
Download 64 bit snapshot from: http://sdcc.sourceforge.net/snap.php#LinuxThe archive file would be named something like:
sdcc-snapshot-amd64-unknown-linux2.5-20180712-10467.tar.bz2
Download it to your ~/Documents directory
Then execute the following commands from the same directory (~/Documents) where you have placed the downloaded archive:
header files into: /usr/local/share/sdcc/include/
non-free header files into: /usr/local/share/sdcc/non-free/include/
library files into: /usr/local/share/sdcc/lib/
non-free library files into: /usr/local/share/sdcc/non-free/lib/
and documentation into: /usr/local/share/sdcc/doc/
- tar xjf ../sdcc-snapshot-amd64-unknown-linux2.5-20180712-10467.tar.bz2
- cd sdcc
- sudo cp -r * /usr/local
header files into: /usr/local/share/sdcc/include/
non-free header files into: /usr/local/share/sdcc/non-free/include/
library files into: /usr/local/share/sdcc/lib/
non-free library files into: /usr/local/share/sdcc/non-free/lib/
and documentation into: /usr/local/share/sdcc/doc/
You can test the install by entering:
/usr/local/bin/sdcc -v
/usr/local/bin/sdcc -v
This should return sdcc's version number, something like:
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.7.1 #10467 (Linux)
published under GNU General Public License (GPL)
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.7.1 #10467 (Linux)
published under GNU General Public License (GPL)
Get the blinky source code and compile it
- Install git if you don't have it installed:
sudo apt-get install git - Clone the repo
- cd ~/Documents
- git clone https://github.com/lithiumhead/Black_Cloud_STC15L2K32S2
- Compile the code
- cd Black_Cloud_STC15L2K32S2/Blinky
- sdcc -mmcs51 --verbose main.c
To remove the generated artifacts, you can use the git command to remove the files with extensions listed in .gitignore:
git clean -fX
git clean -fX
git clean -fX helps remove build artifact |
Download stcgal command line open source in-system programmer
- Install python and stcgal dependencies
- sudo apt install python3 python3-pip
- pip3 install pyserial tqdm
- Clone the git repo and install:
- cd ~/Documents
- git clone https://github.com/grigorig/stcgal
- cd stcgal
- ./setup.py build
- sudo ./setup.py install
- Try downloading the ihx file into Black Board:
- Connect the CH340 USB-Serial board to your Ubuntu Computer. It will appear as /dev/ttyUSB0. The USB-Serial's pin header should be connected to STC15L2K32S2's UART header.
- cd ~/Documents/Black_Cloud_STC15L2K32S2/Blinky
- sudo stcgal -P stc15 -p /dev/ttyUSB0 main.ihx
- Turn on the power to the BlackBoard, this will cause the bootloader to initially run - stcgal will detect it and download the ihx file into the microcontroller's flash memory. The program will run immediately post downloading.
Success downloading ihx to Black Board STC15L2K32S2 |
Blinky running on the Black Board
Next try compiling and downloading the hello world program
- cd ~/Documents/Black_Cloud_STC15L2K32S2/UART_Echo
- sdcc -mmcs51 --verbose main.c
- sudo stcgal -P stc15 -p /dev/ttyUSB0 main.ihx
- sudo apt install minicom
- sudo minicom -D /dev/ttyUSB0
- Configure minicom
- Press Ctrl+A followed by Z
- Press O
- Select "serial port setup"
- press F to change "Hardware Flow Control" to No
- Press Enter
- Select "Save setup as dfl"
- Select exit
- Power cycle the Black Board and you will see the message printed on minicom
- Press Ctrl+A X to leave minicom
Comments
Post a Comment