flash works

This commit is contained in:
hugogogo
2025-03-03 17:35:11 +01:00
parent 71a16df65c
commit 636541eab0
4 changed files with 114 additions and 25 deletions

3
.gitignore vendored
View File

@@ -48,3 +48,6 @@ Thumbs.db
*.mov
*.wmv
# chips
*.bin
*.hex

View File

@@ -1,29 +1,76 @@
# README #
# RESSOURCES #
This README would normally document whatever steps are necessary to get your application up and running.
- https://github.com/m3y54m/start-avr/tree/master
- avrdude 6.3 doc : https://download-mirror.savannah.gnu.org/releases/avrdude/avrdude-doc-6.3.pdf
### What is this repository for? ###
## ex00 ##
* Quick summary
* Version
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
avrdude output without flashing :
```
avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -v
### How do I get set up? ###
avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
* Summary of set up
* Configuration
* Dependencies
* Database configuration
* How to run tests
* Deployment instructions
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/home/hulamy/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
### Contribution guidelines ###
Using Port : /dev/ttyUSB0
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
* Writing tests
* Code review
* Other guidelines
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
### Who do I talk to? ###
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
* Repo owner or admin
* Other community or team contact
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
avrdude done. Thank you.
```

View File

@@ -1,11 +1,50 @@
# Set the frequency of the CPU (in Hz)
# frequency of the CPU (in Hz)
F_CPU = 16000000UL
TARGET = main
CC = avr-gcc
all: hex flash
hex:
# ls /dev/tty* : /dev/ttyUSB0
hex: $(TARGET).hex
# avr-gcc : compiler for AVR microcontrollers, https://gcc.gnu.org/wiki/avr-gcc#Using_avr-gcc, https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
# -mmcu : the target microcontrolle (ATmega328P)
# -D : defines a preprocessor macro (#define F_CPU <value>)
# -o : output filename
$(TARGET).bin: $(TARGET).c
$(CC) -mmcu=atmega328p -D F_CPU=$(F_CPU) $(TARGET).c -o $(TARGET).bin
# avr-objcopy : man avr-jobcopy, https://linux.die.net/man/1/avr-objcopy
# -O : specifies output format, Intel HEX
# some formats (list not found in any doc) :
# -O ihex : Used for flashing AVR chips
# -O binary : Raw binary file
# -O elf32-avr : Used for debugging
$(TARGET).hex: $(TARGET).bin
avr-objcopy -O ihex $(TARGET).bin $(TARGET).hex
# avr-dude : AVR Downloader/UploaDEr, upload firmware, https://avrdudes.github.io/avrdude, v6.3 https://download-mirror.savannah.gnu.org/releases/avrdude/avrdude-doc-6.3.pdf
# -p : specifies the microcontroller -> m328p
# -c : programmer-id
# -b : baud rate for serial communication
# -P : the serial port, found with `ls /dev/tty*` -> /dev/ttyUSB0
# -U : Uploads (w = write) the HEX firmware file to the flash memory
# (-v : verbose info dump)
flash:
avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -v
# avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:w:$(TARGET).hex
dump:
avrdude -p m328p -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:r:dump_atmega328p.hex
clean:
rm -f main.hex main.bin
rm -f main.hex main.bin
.PHONY : all clean hex flash dump

View File

@@ -1,3 +1,3 @@
int main() {
return 0;
int main()
{
}