diff --git a/core/ctk/ctk-vncfont.c b/core/ctk/ctk-vncfont.c index dd2e101fc..a75f28c58 100644 --- a/core/ctk/ctk-vncfont.c +++ b/core/ctk/ctk-vncfont.c @@ -29,7 +29,6 @@ * * This file is part of the Contiki VNC server * - * $Id: ctk-vncfont.c,v 1.1 2006/06/17 22:41:16 adamdunkels Exp $ * */ @@ -37,13 +36,12 @@ #define o 0x01 /* 1001 0010 */ #define X 0x02 /* 1111 0110 */ -#ifdef WITH_AVR +#ifdef __AVR__ #include +const unsigned char vncfont[] PROGMEM = { #else -#define prog_char const unsigned char +const unsigned char vncfont[] = { #endif - -prog_char ctk_vncfont[] = { /* char 0 */ X,o,_,_,_,_, o,X,_,_,_,_, diff --git a/core/loader/elfloader-avr.c b/core/loader/elfloader-avr.c index f009aa402..d6b9bfc87 100644 --- a/core/loader/elfloader-avr.c +++ b/core/loader/elfloader-avr.c @@ -28,14 +28,12 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: elfloader-avr.c,v 1.10 2009/07/16 18:02:34 dak664 Exp $ */ #include #include #include #include -#include "dev/rs232.h" #include "elfloader-arch.h" #include "lib/mmem.h" #include //memset @@ -64,8 +62,8 @@ #define DEBUG 0 #if DEBUG -/*#define PRINTF(...) rs232_print_p(RS232_PORT_1, __VA_ARGS__)*/ -#define PRINTF(...) printf(__VA_ARGS__) +#include +#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) #else #define PRINTF(...) #endif diff --git a/cpu/avr/dev/debug.c b/cpu/avr/dev/debug.c index 9e4fec4e7..bd330f0f1 100644 --- a/cpu/avr/dev/debug.c +++ b/cpu/avr/dev/debug.c @@ -15,7 +15,7 @@ delay(void) } /*-----------------------------------------------------------------------------------*/ static char buffer[40]; -static prog_char hextab[] = +static const char hextab[] PROGMEM = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; /*-----------------------------------------------------------------------------------*/ static void @@ -60,7 +60,7 @@ debug_print16(unsigned short v) } /*-----------------------------------------------------------------------------------*/ void -debug_print(prog_char *str) +debug_print(char *str) { /* unsigned char i; diff --git a/cpu/avr/dev/rs232.c b/cpu/avr/dev/rs232.c index 44621f777..94cf5035f 100644 --- a/cpu/avr/dev/rs232.c +++ b/cpu/avr/dev/rs232.c @@ -384,14 +384,6 @@ rs232_set_input(uint8_t port, int (*f)(unsigned char)) #endif } -void -rs232_print_p(uint8_t port, prog_char *buf) -{ - while(pgm_read_byte(buf)) { - rs232_send(port, pgm_read_byte(buf)); - ++buf; - } -} /*---------------------------------------------------------------------------*/ void rs232_print(uint8_t port, char *buf) diff --git a/cpu/avr/dev/rs232.h b/cpu/avr/dev/rs232.h index 531459007..c1b1de415 100644 --- a/cpu/avr/dev/rs232.h +++ b/cpu/avr/dev/rs232.h @@ -31,7 +31,6 @@ * Author: Adam Dunkels * Simon Barner * - * @(#)$Id: rs232.h,v 1.6 2008/11/29 18:36:12 c_oflynn Exp $ */ #ifndef __RS232_H__ @@ -111,19 +110,6 @@ rs232_set_input(uint8_t port, int (* f)(unsigned char)); * configured for this function to work. */ void -rs232_print_p(uint8_t port, prog_char *buf); - -/** - * \brief Print a text string on RS232 - * \param port The RS232 port to be used. - * \param str A pointer to the string that is to be printed - * - * This function prints a string to RS232. The string must - * be terminated by a null byte. The RS232 module must be - * correctly initalized and configured for this function - * to work. - */ -void rs232_print(uint8_t port, char *buf); /** diff --git a/cpu/avr/dev/usb/compiler.h b/cpu/avr/dev/usb/compiler.h index 4a398f5d2..e60828eb3 100644 --- a/cpu/avr/dev/usb/compiler.h +++ b/cpu/avr/dev/usb/compiler.h @@ -332,7 +332,7 @@ typedef char r_uart_ptchar; #define _ConstType_ __flash #define _MemType_ #define _GenericType_ __generic -#define FLASH PROGMEM +#define FLASH const PROGMEM #define XDATA #define IDATA #define DATA diff --git a/cpu/avr/dev/usb/rndis/rndis.c b/cpu/avr/dev/usb/rndis/rndis.c index 42c3b2b4e..8cef778b7 100644 --- a/cpu/avr/dev/usb/rndis/rndis.c +++ b/cpu/avr/dev/usb/rndis/rndis.c @@ -93,7 +93,7 @@ extern U8 data_to_transfer; /** * \brief List of supported RNDIS OID's */ -prog_uint32_t OIDSupportedList[] = { +const uint32_t OIDSupportedList[] PROGMEM = { /* Required General */ OID_GEN_SUPPORTED_LIST , OID_GEN_HARDWARE_STATUS , diff --git a/cpu/avr/dev/usb/usb_standard_request.c b/cpu/avr/dev/usb/usb_standard_request.c index 93ac02d0b..7371f63f8 100644 --- a/cpu/avr/dev/usb/usb_standard_request.c +++ b/cpu/avr/dev/usb/usb_standard_request.c @@ -250,6 +250,7 @@ void usb_get_string_descriptor_sram(U8 string_type) { dummy = Usb_read_byte(); //!< don't care of wIndex field dummy = Usb_read_byte(); + if (dummy) {;} //avoid gcc unused variable warning requested_length = Usb_read_byte(); //!< read wLength requested_length |= Usb_read_byte()<<8; @@ -341,6 +342,7 @@ void usb_get_string_descriptor(U8 string_type) { dummy = Usb_read_byte(); //!< don't care of wIndex field dummy = Usb_read_byte(); + if (dummy) {;} requested_length = Usb_read_byte(); //!< read wLength requested_length |= Usb_read_byte()<<8; @@ -468,6 +470,7 @@ void usb_get_descriptor(void) default: dummy = Usb_read_byte(); dummy = Usb_read_byte(); + if (dummy) {;} LSBwLength = Usb_read_byte(); MSBwLength = Usb_read_byte(); byteswereread=1; @@ -567,6 +570,7 @@ U8 dummy; dummy = Usb_read_byte(); //!< dummy read dummy = Usb_read_byte(); //!< dummy read + if (dummy) {;} wIndex = Usb_read_byte(); switch(bmRequestType) @@ -617,6 +621,7 @@ U8 dummy; { wValue = Usb_read_byte(); dummy = Usb_read_byte(); //!< dummy read + if (dummy) {;} if (wValue == FEATURE_ENDPOINT_HALT) { @@ -673,6 +678,7 @@ U8 dummy; { wValue = Usb_read_byte(); dummy = Usb_read_byte(); //!< dummy read + if (dummy) {;} if (wValue == FEATURE_ENDPOINT_HALT) { @@ -730,6 +736,7 @@ void usb_set_interface (void) alt_setting = Usb_read_byte(); dummy = Usb_read_byte(); + if (dummy) {;} interface = Usb_read_byte(); if(usb_user_set_alt_interface(interface, alt_setting)) { diff --git a/platform/avr-atmega128rfa1/params.c b/platform/avr-atmega128rfa1/params.c index 480ee3ee5..aadbb83c4 100644 --- a/platform/avr-atmega128rfa1/params.c +++ b/platform/avr-atmega128rfa1/params.c @@ -77,9 +77,9 @@ extern uint8_t default_mac_address[8]; extern uint8_t default_server_name[16]; extern uint8_t default_domain_name[30]; #else -uint8_t default_mac_address[8] PROGMEM = PARAMS_EUI64ADDR; -uint8_t default_server_name[] PROGMEM = PARAMS_SERVERNAME; -uint8_t default_domain_name[] PROGMEM = PARAMS_DOMAINNAME; +const uint8_t default_mac_address[8] PROGMEM = PARAMS_EUI64ADDR; +const uint8_t default_server_name[] PROGMEM = PARAMS_SERVERNAME; +const uint8_t default_domain_name[] PROGMEM = PARAMS_DOMAINNAME; #endif #if PARAMETER_STORAGE==0 diff --git a/platform/avr-raven/params.c b/platform/avr-raven/params.c index 480ee3ee5..aadbb83c4 100644 --- a/platform/avr-raven/params.c +++ b/platform/avr-raven/params.c @@ -77,9 +77,9 @@ extern uint8_t default_mac_address[8]; extern uint8_t default_server_name[16]; extern uint8_t default_domain_name[30]; #else -uint8_t default_mac_address[8] PROGMEM = PARAMS_EUI64ADDR; -uint8_t default_server_name[] PROGMEM = PARAMS_SERVERNAME; -uint8_t default_domain_name[] PROGMEM = PARAMS_DOMAINNAME; +const uint8_t default_mac_address[8] PROGMEM = PARAMS_EUI64ADDR; +const uint8_t default_server_name[] PROGMEM = PARAMS_SERVERNAME; +const uint8_t default_domain_name[] PROGMEM = PARAMS_DOMAINNAME; #endif #if PARAMETER_STORAGE==0 diff --git a/platform/avr-ravenusb/contiki-raven-main.c b/platform/avr-ravenusb/contiki-raven-main.c index b2abe2e21..37fdf49da 100644 --- a/platform/avr-ravenusb/contiki-raven-main.c +++ b/platform/avr-ravenusb/contiki-raven-main.c @@ -151,7 +151,7 @@ const struct uip_fallback_interface rpl_interface = { #include "net/rpl/rpl.h" // avr-objdump --section .bss -x ravenusbstick.elf -uint16_t dag_id[] PROGMEM = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011}; +const uint16_t dag_id[] PROGMEM = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011}; PROCESS(border_router_process, "RPL Border Router"); PROCESS_THREAD(border_router_process, ev, data) @@ -220,26 +220,26 @@ SIGNATURE = { FUSES ={.low = 0xde, .high = 0x99, .extended = 0xff,}; /* Save the default settings into program flash memory */ -uint8_t default_mac_address[8] PROGMEM = {0x02, 0x12, 0x13, 0xff, 0xfe, 0x14, 0x15, 0x16}; +const uint8_t default_mac_address[8] PROGMEM = {0x02, 0x12, 0x13, 0xff, 0xfe, 0x14, 0x15, 0x16}; #ifdef CHANNEL_802_15_4 -uint8_t default_channel PROGMEM = CHANNEL_802_15_4; +const uint8_t default_channel PROGMEM = CHANNEL_802_15_4; #else -uint8_t default_channel PROGMEM = 26; +const uint8_t default_channel PROGMEM = 26; #endif #ifdef IEEE802154_PANID -uint16_t default_panid PROGMEM = IEEE802154_PANID; +const uint16_t default_panid PROGMEM = IEEE802154_PANID; #else -uint16_t default_panid PROGMEM = 0xABCD; +const uint16_t default_panid PROGMEM = 0xABCD; #endif #ifdef IEEE802154_PANADDR -uint16_t default_panaddr PROGMEM = IEEE802154_PANID; +const uint16_t default_panaddr PROGMEM = IEEE802154_PANID; #else -uint16_t default_panaddr PROGMEM = 0; +const uint16_t default_panaddr PROGMEM = 0; #endif #ifdef RF230_MAX_TX_POWER -uint8_t default_txpower PROGMEM = RF230_MAX_TX_POWER; +const uint8_t default_txpower PROGMEM = RF230_MAX_TX_POWER; #else -uint8_t default_txpower PROGMEM = 0; +const uint8_t default_txpower PROGMEM = 0; #endif #if JACKDAW_CONF_RANDOM_MAC diff --git a/platform/avr-ravenusb/httpd-simple-avr.c b/platform/avr-ravenusb/httpd-simple-avr.c index 9c40d4e79..a82921342 100644 --- a/platform/avr-ravenusb/httpd-simple-avr.c +++ b/platform/avr-ravenusb/httpd-simple-avr.c @@ -146,13 +146,13 @@ PT_THREAD(send_string_P(struct httpd_state *s, char *str)) } #endif /*---------------------------------------------------------------------------*/ -char http_content_type_html[] PROGMEM = "Content-type: text/html\r\n\r\n"; +const char http_content_type_html[] PROGMEM = "Content-type: text/html\r\n\r\n"; static -PT_THREAD(send_headers(struct httpd_state *s, char *statushdr)) +PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr)) { PSOCK_BEGIN(&s->sout); - PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, statushdr); - PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, http_content_type_html); + PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) statushdr); + PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) http_content_type_html); PSOCK_END(&s->sout); } /*---------------------------------------------------------------------------*/ @@ -241,9 +241,9 @@ ipaddr_add(const uip_ipaddr_t *addr) } } /*---------------------------------------------------------------------------*/ -char TOP1[] PROGMEM = "ContikiRPL(Jackdaw)"; -char TOP2[] PROGMEM = ""; -char BOTTOM[] PROGMEM = ""; +const char TOP1[] PROGMEM = "ContikiRPL(Jackdaw)"; +const char TOP2[] PROGMEM = ""; +const char BOTTOM[] PROGMEM = ""; #if UIP_CONF_IPV6 extern uip_ds6_nbr_t uip_ds6_nbr_cache[]; extern uip_ds6_route_t uip_ds6_routing_table[]; @@ -255,8 +255,8 @@ PT_THREAD(generate_routes(struct httpd_state *s)) uint8_t i=0; PSOCK_BEGIN(&s->sout); - PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, TOP1); - PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, TOP2); + PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) TOP1); + PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) TOP2); #if UIP_CONF_IPV6 //allow ip4 builds blen = 0; @@ -305,7 +305,7 @@ PT_THREAD(generate_routes(struct httpd_state *s)) PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); #endif /* UIP_CONF_IPV6 */ - PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, BOTTOM); + PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) BOTTOM); PSOCK_END(&s->sout); } @@ -317,9 +317,9 @@ httpd_simple_get_script(const char *name) return generate_routes; } /*---------------------------------------------------------------------------*/ -char http_header_200[] PROGMEM = "HTTP/1.0 200 OK\r\nServer: Jackdaw\r\nConnection: close\r\n"; -char http_header_404[] PROGMEM = "HTTP/1.0 404 Not found\r\nServer: Jackdaw\r\nConnection: close\r\n"; -char NOT_FOUND[] PROGMEM = "

404 - file not found

"; +const char http_header_200[] PROGMEM = "HTTP/1.0 200 OK\r\nServer: Jackdaw\r\nConnection: close\r\n"; +const char http_header_404[] PROGMEM = "HTTP/1.0 404 Not found\r\nServer: Jackdaw\r\nConnection: close\r\n"; +const char NOT_FOUND[] PROGMEM = "

404 - file not found

"; static PT_THREAD(handle_output(struct httpd_state *s)) { diff --git a/platform/stk501/contiki-stk501-main.c b/platform/stk501/contiki-stk501-main.c index 38ee2dc85..0baf2a259 100644 --- a/platform/stk501/contiki-stk501-main.c +++ b/platform/stk501/contiki-stk501-main.c @@ -58,6 +58,8 @@ /* Uncomment to enable demonstration of multi-threading libary */ /* #define MT_DEMO */ +#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) + //TODO: What happened to cfs_eeprom_process? //PROCINIT(&etimer_process, &tcpip_process, &uip_fw_process, &cfs_eeprom_process); #if UIP_CONF_IPV6 @@ -72,8 +74,7 @@ static struct mt_thread threads[3]; static void thread_handler1 (void* data) { while (1) { - rs232_print_p (RS232_PORT_1, PSTR ("Thread 1. Data: ") ); - rs232_printf (RS232_PORT_1, "0x%x, %d\n", data, *(uint8_t*)data ); + PRINTF ("Thread 1. Data: 0x%x, %d\n", data, *(uint8_t*)data ); mt_yield (); } } @@ -81,8 +82,7 @@ void thread_handler1 (void* data) { static void thread_handler2 (void* data) { while (1) { - rs232_print_p (RS232_PORT_1, PSTR ("Thread 2. Data: ")); - rs232_printf (RS232_PORT_1, "0x%x, %d\n", data, *(uint8_t*)data ); + PRINTF ("Thread 2. Data: 0x%x, %d\n", data, *(uint8_t*)data ); mt_yield (); } } @@ -138,7 +138,7 @@ main(void) /* Perform rest of initializations */ process_start(&contiki_stk501_main_init_process, NULL); - rs232_print_p (RS232_PORT_1, PSTR ("Initialized.\n")); + PRINTF"Initialized.\n"); #ifdef MT_DEMO mt_start (&threads[0], thread_handler1, &d1); diff --git a/tools/avr-make-symbols b/tools/avr-make-symbols index d8365f5ba..83c6e591b 100755 --- a/tools/avr-make-symbols +++ b/tools/avr-make-symbols @@ -13,7 +13,7 @@ echo \#endif >> symbols.h echo \#include '"symbols.h"' > symbols.c echo \#include '' >> symbols.c -$NM $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "static const prog_char s_$1 [] = \"$1\";\n" if(/(\w+) = (\w+)/)' | sort >> symbols.c +$NM $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "static const unsigned char s_$1 [] PROGMEM = \"$1\";\n" if(/(\w+) = (\w+)/)' | sort >> symbols.c echo "PROGMEM const struct symbols symbols[] = {" >> symbols.c avr-nm $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "{(const char*)s_$1, (void*)$2},\n" if(/(\w+) = (\w+)/)' | sort >> symbols.c