From abac0f038195285e4d3c1ce1cf4a8d0703bd92a0 Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Sat, 29 Nov 2014 14:14:35 +0100 Subject: [PATCH 1/7] Fix compilation of er-rest-example --- platform/avr-raven/contiki-conf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/avr-raven/contiki-conf.h b/platform/avr-raven/contiki-conf.h index 2fe0d6099..ead35168b 100644 --- a/platform/avr-raven/contiki-conf.h +++ b/platform/avr-raven/contiki-conf.h @@ -162,6 +162,7 @@ typedef unsigned short uip_stats_t; #define UIP_CONF_ICMP6 1 #define UIP_CONF_UDP 1 #define UIP_CONF_TCP 1 +#define UIP_CONF_BUFFER_SIZE 1300 #define NETSTACK_CONF_NETWORK sicslowpan_driver #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 #else From 65e70baa841d0c55b57e91235899928ee6c6da69 Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Sat, 29 Nov 2014 15:40:31 +0100 Subject: [PATCH 2/7] Tables must be const in order to be put into read-only section by means of __attribute__((progmem)) (avr-gcc 4.7.0) --- platform/avr-ravenlcd/beep.c | 13 +++++++------ platform/avr-ravenlcd/temp.c | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/avr-ravenlcd/beep.c b/platform/avr-ravenlcd/beep.c index 34f2ee23f..cb2a0510b 100644 --- a/platform/avr-ravenlcd/beep.c +++ b/platform/avr-ravenlcd/beep.c @@ -132,11 +132,11 @@ beep(void) static uint8_t tuneindex=0; -static uint8_t pictures[] PROGMEM = {G4,4, F4,4, AS4,4, C5,2, F5,2, D5,4, C5,2, F5,2, D5,4, AS4,4, C5,4, G4,4, F4,4, 0xff}; -static uint8_t axel[] PROGMEM = {FS4,2, NONE,2, A4,3, FS4,2, FS4,1, B4,2, FS4,2, E4,2, FS4,2, NONE,2, CS5,3, FS4,2, FS4,1, D5,2, CS5,2, A4,2, FS4,2, CS5,2, FS5,2, FS4,1, E4,2, E4,1, CS4,2, GS4,2, FS4,6, 0xff}; -static uint8_t sandman1[] PROGMEM = {F4,2, G4,2, B4,4, A4,10, B4,2, B4,2, A4,2, B4,12, 0xff}; -static uint8_t sandman2[] PROGMEM = {C4,2, E4,2, G4,2, B4,2, A4,2, G4,2, E4,2, C4,2, D4,2, F4,2, A4,2, C5,2, B4,8, 0xff}; -static uint8_t furelise[] PROGMEM = {E5,1, DS5,1, E5,1, DS5,1, E5,1, B4,1, D5,1, E5,1, A4,2, NONE,1, C4,1, E4,1, A4,1, B4,2, NONE,1, E4,1, GS4,1, B4,1, C5,2, 0xff}; +static const uint8_t pictures[] PROGMEM = {G4,4, F4,4, AS4,4, C5,2, F5,2, D5,4, C5,2, F5,2, D5,4, AS4,4, C5,4, G4,4, F4,4, 0xff}; +static const uint8_t axel[] PROGMEM = {FS4,2, NONE,2, A4,3, FS4,2, FS4,1, B4,2, FS4,2, E4,2, FS4,2, NONE,2, CS5,3, FS4,2, FS4,1, D5,2, CS5,2, A4,2, FS4,2, CS5,2, FS5,2, FS4,1, E4,2, E4,1, CS4,2, GS4,2, FS4,6, 0xff}; +static const uint8_t sandman1[] PROGMEM = {F4,2, G4,2, B4,4, A4,10, B4,2, B4,2, A4,2, B4,12, 0xff}; +static const uint8_t sandman2[] PROGMEM = {C4,2, E4,2, G4,2, B4,2, A4,2, G4,2, E4,2, C4,2, D4,2, F4,2, A4,2, C5,2, B4,8, 0xff}; +static const uint8_t furelise[] PROGMEM = {E5,1, DS5,1, E5,1, DS5,1, E5,1, B4,1, D5,1, E5,1, A4,2, NONE,1, C4,1, E4,1, A4,1, B4,2, NONE,1, E4,1, GS4,1, B4,1, C5,2, 0xff}; static volatile uint8_t icnt,tone; @@ -153,7 +153,8 @@ ISR(TIMER0_OVF_vect) void play_ringtone(void) { -uint8_t i,*noteptr; +uint8_t i; +const uint8_t *noteptr; /* What's next on the playlist? */ switch (tuneindex++) { diff --git a/platform/avr-ravenlcd/temp.c b/platform/avr-ravenlcd/temp.c index cf7c20c31..e7e8243b6 100644 --- a/platform/avr-ravenlcd/temp.c +++ b/platform/avr-ravenlcd/temp.c @@ -58,7 +58,7 @@ static uint16_t temp_table_celcius[]; static uint16_t temp_table_fahrenheit[]; #else /* !DOXYGEN */ /** Celcius temperatures (ADC-value) from -15 to 60 degrees */ -static uint16_t temp_table_celcius[] PROGMEM = { +static const uint16_t temp_table_celcius[] PROGMEM = { 923,917,911,904,898,891,883,876,868,860,851,843,834,825,815, 806,796,786,775,765,754,743,732,720,709,697,685,673,661,649, 636,624,611,599,586,574,562,549,537,524,512,500,488,476,464, @@ -68,7 +68,7 @@ static uint16_t temp_table_celcius[] PROGMEM = { }; /** Fahrenheit temperatures (ADC-value) from 0 to 140 degrees */ -static uint16_t temp_table_fahrenheit[] PROGMEM = { +static const uint16_t temp_table_fahrenheit[] PROGMEM = { 938, 935, 932, 929, 926, 923, 920, 916, 913, 909, 906, 902, 898, 894, 891, 887, 882, 878, 874, 870, 865, 861, 856, 851, 847, 842, 837, 832, 827, 822, 816, 811, 806, 800, 795, 789, 783, 778, 772, @@ -99,7 +99,7 @@ bool temp_initialized = false; * * \return EOF on error */ -static int find_temp(int16_t value, uint16_t* array, int count); +static int find_temp(int16_t value, const uint16_t* array, int count); /*---------------------------------------------------------------------------*/ @@ -232,7 +232,7 @@ temp_get(temp_unit_t unit) * \return EOF on error */ static int -find_temp(int16_t value, uint16_t* array, int count) +find_temp(int16_t value, const uint16_t* array, int count) { int i = 0; int table_val = 0; From a3435952efe89506958f891c51d93316a23079dc Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Wed, 3 Dec 2014 00:07:55 +0100 Subject: [PATCH 3/7] Only output data and text sections to the hex file --- platform/avr-ravenlcd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/avr-ravenlcd/Makefile b/platform/avr-ravenlcd/Makefile index e16132765..fef0167d9 100644 --- a/platform/avr-ravenlcd/Makefile +++ b/platform/avr-ravenlcd/Makefile @@ -28,7 +28,7 @@ LDFLAGS = $(COMMON) LDFLAGS += -Wl,-Map=$(PROJECT).map,--cref ## Intel Hex file production flags -HEX_FLASH_FLAGS = -R .eeprom +HEX_FLASH_FLAGS = -j .text -j .data HEX_EEPROM_FLAGS = -j .eeprom HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" From 8e02955c3dce4b512b83ef2fda989577fb8abfad Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Wed, 3 Dec 2014 00:12:43 +0100 Subject: [PATCH 4/7] Fix menu. How could it worked before? Also added a macro to disable JTAG using inline assembly --- platform/avr-ravenlcd/menu.c | 38 +++++++++++++++++++++---------- platform/avr-ravenlcd/raven3290.c | 8 +++---- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/platform/avr-ravenlcd/menu.c b/platform/avr-ravenlcd/menu.c index a5cda40a9..3069d7825 100644 --- a/platform/avr-ravenlcd/menu.c +++ b/platform/avr-ravenlcd/menu.c @@ -66,6 +66,27 @@ bool auto_temp=true; /*---------------------------------------------------------------------------*/ +/** + * \brief This will reliably set or clear the JTD bit of the MCUCR register. + * + * \param x True to set the JTD bit disabling JTAG. +*/ +#define jtd_set(x)\ +{\ + __asm__ __volatile__ (\ + "in __tmp_reg__,__SREG__" "\n\t"\ + "cli" "\n\t"\ + "out %1, %0" "\n\t"\ + "out __SREG__, __tmp_reg__" "\n\t"\ + "out %1, %0" "\n\t"\ + : /* no outputs */\ + : "r" ((uint8_t)(x ? (1< Date: Sat, 19 Sep 2015 15:45:09 +0200 Subject: [PATCH 5/7] See https://sourceforge.net/p/contiki/mailman/message/31702228/ --- platform/avr-raven/apps/raven-webserver/httpd-cgi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c index f085991bf..874ad4246 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c +++ b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c @@ -368,7 +368,7 @@ make_routes(void *p) j++; numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); - numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted); + numprinted += httpd_cgi_sprint_ip6(*uip_ds6_route_nexthop(r), uip_appdata + numprinted); if(r->state.lifetime < 3600) { numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); } else { From 018be89b1109c7da3288d702f4392d887611534c Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Sun, 20 Sep 2015 23:56:53 +0200 Subject: [PATCH 6/7] Revert abs -> ABS change from commit 0dab6926b30647e4c3bb1b56f39ccef761733ef5. The avr-ravenlcd cannot include sys/cc.h since this in turns includes contiki-conf.h which the avr-ravenlcd does not have. --- platform/avr-ravenlcd/lcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/avr-ravenlcd/lcd.c b/platform/avr-ravenlcd/lcd.c index 3c4f9e230..0fe92b80a 100644 --- a/platform/avr-ravenlcd/lcd.c +++ b/platform/avr-ravenlcd/lcd.c @@ -411,7 +411,7 @@ lcd_num_putdec(int numb, lcd_padding_t padding) } /* Convert to BCD */ - bcd = itobcd(ABS(numb)); + bcd = itobcd(abs(numb)); /* Print */ return lcd_num_print(bcd, (bool)(numb<0), padding); From e51783a1d542b34fd490ce92d08f5560316370c1 Mon Sep 17 00:00:00 2001 From: Cristiano De Alti Date: Mon, 21 Sep 2015 21:56:09 +0200 Subject: [PATCH 7/7] Most of the rules in the avr makefile are not used anymore and should be removed. In the meantime we change those needed to upload flash and eeprom to depend on the default contiki rule to make the .$(TARGET) executable." --- cpu/avr/Makefile.avr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu/avr/Makefile.avr b/cpu/avr/Makefile.avr index 7ca45bf05..73c662582 100644 --- a/cpu/avr/Makefile.avr +++ b/cpu/avr/Makefile.avr @@ -139,10 +139,10 @@ ifndef NOAVRSIZE avr-size -C --mcu=$(MCU) $@ endif -%.hex: %.out +%.hex: %.$(TARGET) $(OBJCOPY) $^ -j .text -j .data -O ihex $@ -%.ihex: %.out +%.ihex: %.$(TARGET) $(OBJCOPY) $^ -O ihex $@ # Add a namelist to the kernel @@ -160,7 +160,7 @@ endif #%.hex: %.elf # $(OBJCOPY) -R .eeprom -R .fuse -R .signature $^ -O ihex $@ -%.eep: %.out +%.eep: %.$(TARGET) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex $^ $@