PROGMEM changes needed for newer avr-gcc compiler

This commit is contained in:
David Kopf 2012-02-21 11:10:57 -05:00
parent 5fdcd6bc13
commit 6e45dfe5ff
14 changed files with 51 additions and 70 deletions

View File

@ -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 <avr/pgmspace.h>
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,_,_,_,_,

View File

@ -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 <stdio.h>
#include <avr/boot.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "dev/rs232.h"
#include "elfloader-arch.h"
#include "lib/mmem.h"
#include <string.h> //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 <avr/pgmspace.h>
#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
#else
#define PRINTF(...)
#endif

View File

@ -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;

View File

@ -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)

View File

@ -31,7 +31,6 @@
* Author: Adam Dunkels <adam@sics.se>
* Simon Barner <barner@in.tum.de>
*
* @(#)$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);
/**

View File

@ -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

View File

@ -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 ,

View File

@ -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)) {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 = "<html><head><title>ContikiRPL(Jackdaw)";
char TOP2[] PROGMEM = "</title></head><body>";
char BOTTOM[] PROGMEM = "</body></html>";
const char TOP1[] PROGMEM = "<html><head><title>ContikiRPL(Jackdaw)";
const char TOP2[] PROGMEM = "</title></head><body>";
const char BOTTOM[] PROGMEM = "</body></html>";
#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 = "<html><body bgcolor=\"white\"><center><h1>404 - file not found</h1></center></body></html>";
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 = "<html><body bgcolor=\"white\"><center><h1>404 - file not found</h1></center></body></html>";
static
PT_THREAD(handle_output(struct httpd_state *s))
{

View File

@ -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);

View File

@ -13,7 +13,7 @@ echo \#endif >> symbols.h
echo \#include '"symbols.h"' > symbols.c
echo \#include '<avr/pgmspace.h>' >> 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