https://github.com/OscarBratli/Byggern
wiring_tables.md contains lists of the pin connections.
Some code, including comments, documentation and scripts in this repository was created with assistance from AI tools like Github Copilot.
The steps below are explained in more detail in page 22 of the lab manual
sudo apt install gcc-arm-none-eabi
sudo apt install libusb-dev libusb-1.0-0-dev libusb-1.0-0
sudo apt install libhidapi-dev libftdi-dev libftdi1-dev
These are likely required for building openocd on Ubuntu in WSL
sudo apt install pkg-config libjim-dev
sudo apt install gcc-avr binutils-avr avr-libc
git clone https://git.code.sf.net/p/openocd/code openocd
cd openocd
./bootstrap
mkdir build; cd build
../configure --enable-cmsis-dap --enable-openjtag --prefix=/opt/openocd
make
sudo make install
To flash the Arduino Due without requiring sudo every time, you need to add udev rules for the Atmel ICE debugger:
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2141", MODE="0666", GROUP="dialout"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2141", MODE="0666", GROUP="dialout"' | sudo tee /etc/udev/rules.d/99-atmel-ice.rules
sudo udevadm control --reload-rules && sudo udevadm triggerAfter running these commands:
- Unplug the Atmel ICE debugger USB cable
- Wait 2 seconds
- Plug it back in
- Now
make flashwill work without sudo
Note: You'll need to run these commands on each new computer you use for development.
make
make memory
Shows detailed memory usage with percentages for the ATmega162:
AVR Memory Usage
----------------
Device: atmega162
Program: 12736 bytes (77.7% Full)
(.text + .data + .bootloader)
Data: 758 bytes (74.0% Full)
(.data + .bss + .noinit)
make size
Shows raw memory section sizes in bytes:
text data bss dec hex filename
12022 714 44 12780 31ec build/a.out
Section explanations:
- text: Program code (flash memory)
- data: Initialized variables (RAM + flash)
- bss: Uninitialized variables (RAM only)
- dec/hex: Total memory usage in decimal/hexadecimal
make flash
Run the following command, where /dev/ttyS0 is the device and 9600 is the baud rate in a terminal to open the serial communication
sudo screen /dev/ttyS0 9600
If the serial port is started with the command above, there is a chance it was not gracefully shut down, and the screen instance is still watching the port. This might interfere with the operation of the serial port and data may be lost. To fix this, check if there are any applications currently using the serial port using this command.
sudo lsof /dev/ttyS0
And kill the applications listed.
sudo pkill screen
Include a definition in .vscode/c_cpp_properties.json such that the IDE can recognize the IO config
"defines": [
"__AVR_ATmega162__"
],Specify the following in the Makefile such that the compiler can recognize the IO config
TARGET_CPU := atmega162
TARGET_DEVICE := m162