Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avrdude will not compile with current (Debian GNU/Linux) avr-gcc #1

Open
jmfriedt opened this issue Dec 21, 2024 · 2 comments
Open

Comments

@jmfriedt
Copy link

On current Debian GNU/Linux using avr-gcc (GCC) 14.2.0, patching avrdude with

+void gdbsrv_disable (const struct programmer_t *pgm){
+    gdb_wrt(pgm, "qRcmd,7265"); //reset
+    if(gdb_recv(pgm, buf, 1024)) return -1;
+    if(strncmp(buf, "OK", 2)) return -2;

fails with the error that a void function cannot return, and

+int gdbsrv_read_sig_bytes (const struct programmer_t *pgm, AVRPART *p, const AVRMEM *m){

fails with the missing const prefix to AVRPART, whose addition leads to the error in the assignments

+    p->signature[0] = m->buf[0];
+    p->signature[1] = m->buf[1];
+    p->signature[2] = m->buf[2];
@tetofonta
Copy link
Owner

It is strange that this has been hidden for a long time... My fault. The returns were used as an error code, so you can
use a return statement without values. I'll fix this when possible.

@jmfriedt
Copy link
Author

Please find the list of changes I had to include in your patch to get avrdude, checkout 3e49f07, to compile (a few returns to satisfy the function prototypes, and a const argument I had to override to be allowed to set its entries):

diff --git a/avrdude.patch b/avrdude.patch
index cb05e2d..6fb4869 100644
--- a/avrdude.patch
+++ b/avrdude.patch
@@ -3,7 +3,7 @@ new file mode 100644
 index 0000000..cfdbfe5
 --- /dev/null
 +++ b/src/avrisp_raw_serial_to_spi.c
-@@ -0,0 +1,300 @@
+@@ -0,0 +1,302 @@
 +//
 +// Created by stefano on 24/08/22.
 +//
@@ -221,6 +221,7 @@ index 0000000..cfdbfe5
 +        addr++;
 +        x += 2;
 +    }
++    return 0;
 +}
 +
 +static int avrisp_serial_spi_paged_load_eeprom(const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m,
@@ -272,9 +273,10 @@ index 0000000..cfdbfe5
 +
 +int avrisp_serial_spi_pgm_led(const struct programmer_t *pgm, int value) {
 +    avr_serial_spi_command(pgm, 0x04 | (~value & 1));
++    return(0);
 +}
 +
-+int avrisp_serial_spi_foo_led(const struct programmer_t *pgm, int value) {}
++int avrisp_serial_spi_foo_led(const struct programmer_t *pgm, int value) {return(0);}
 +
 +const char avrisp_serial_spi_desc[] = "AvrISP serial to spi raw adapter";
 +
@@ -327,7 +329,7 @@ new file mode 100644
 index 0000000..415ea3f
 --- /dev/null
 +++ b/src/gdb_server_programmer.c
-@@ -0,0 +1,251 @@
+@@ -0,0 +1,252 @@
 +//
 +// Created by stefano on 24/08/22.
 +//
@@ -451,8 +453,8 @@ index 0000000..415ea3f
 +void gdbsrv_enable (struct programmer_t *pgm, const AVRPART *p){}
 +void gdbsrv_disable (const struct programmer_t *pgm){
 +    gdb_wrt(pgm, "qRcmd,7265"); //reset
-+    if(gdb_recv(pgm, buf, 1024)) return -1;
-+    if(strncmp(buf, "OK", 2)) return -2;
++    if(gdb_recv(pgm, buf, 1024)) return;
++    if(strncmp(buf, "OK", 2)) return;
 +
 +    gdb_wrt(pgm, "C");
 +}
@@ -484,7 +486,7 @@ index 0000000..415ea3f
 +void gdbsrv_powerup (const struct programmer_t *pgm){}
 +void gdbsrv_powerdown (const struct programmer_t *pgm){}
 +
-+int gdbsrv_program_enable (const struct programmer_t *pgm, const AVRPART *p){}
++int gdbsrv_program_enable (const struct programmer_t *pgm, const AVRPART *p){return(0);}
 +
 +int gdbsrv_chip_erase (const struct programmer_t *pgm, const AVRPART *p){
 +    avrdude_message(MSG_INFO, "chip_erase\n");
@@ -539,7 +541,8 @@ index 0000000..415ea3f
 +    return 0;
 +}
 +
-+int gdbsrv_read_sig_bytes (const struct programmer_t *pgm, AVRPART *p, const AVRMEM *m){
++int gdbsrv_read_sig_bytes (const struct programmer_t *pgm, const AVRPART *p, const AVRMEM *m){
++    AVRPART *ptmp=(AVRPART *)p;
 +    gdb_wrt(pgm, "qRcmd,73"); //s[ignature]
 +    if(gdb_recv(pgm, buf, 1024)) return -1;
 +    parse_monitor_answer(buf, 1024);
@@ -549,9 +552,9 @@ index 0000000..415ea3f
 +    m->buf[2] = 0;
 +
 +    //todo signature verification for debug_wire
-+    p->signature[0] = m->buf[0];
-+    p->signature[1] = m->buf[1];
-+    p->signature[2] = m->buf[2];
++    ptmp->signature[0] = m->buf[0];
++    ptmp->signature[1] = m->buf[1];
++    ptmp->signature[2] = m->buf[2];
 +
 +    if(gdb_recv(pgm, buf, 1024)) return -1; // OK
 +    return 0;

@jmfriedt jmfriedt changed the title avrdude will not comply with current (Debian GNU/Linux) avr-gcc avrdude will not compile with current (Debian GNU/Linux) avr-gcc Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants