* [ECOS] Reading flash config value from application
@ 2006-06-16 23:23 André-John Mas
2006-06-17 1:41 ` Gary Thomas
0 siblings, 1 reply; 6+ messages in thread
From: André-John Mas @ 2006-06-16 23:23 UTC (permalink / raw)
To: ecos-discuss
Hi,
I use fconfig in my redboot to set an IP address for my card. What is
the
best way to read this IP address from my application, since
flash_config.h
seems to be part of the Redboot package.
Andre
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Reading flash config value from application
2006-06-16 23:23 [ECOS] Reading flash config value from application André-John Mas
@ 2006-06-17 1:41 ` Gary Thomas
[not found] ` <FAE7AB22-59C4-4C01-8C7E-AC3C86F6E3F1@sympatico.ca>
0 siblings, 1 reply; 6+ messages in thread
From: Gary Thomas @ 2006-06-17 1:41 UTC (permalink / raw)
To: André-John Mas; +Cc: ecos-discuss
On Fri, 2006-06-16 at 19:22 -0400, André-John Mas wrote:
> Hi,
>
> I use fconfig in my redboot to set an IP address for my card. What is
> the
> best way to read this IP address from my application, since
> flash_config.h
> seems to be part of the Redboot package.
You can do this using the Virtual Vectors interface into RedBoot.
The call:
CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
<fconfig_name>,
&result,
<type>)
Where <fconfig_name> is a string containing the 'fconfig' short name for
the data item (use 'fc -l -n' to see what the names are). The variable
<type> defines the type of data. You can find the #define's for these
in the include file "flash_config.h".
Note: the result of this call is a boolean - true if the data was
found, false if not.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Reading flash config value from application
@ 2006-06-20 22:26 Andre-John Mas
2006-06-21 2:15 ` Gary Thomas
0 siblings, 1 reply; 6+ messages in thread
From: Andre-John Mas @ 2006-06-20 22:26 UTC (permalink / raw)
To: ecos-discuss
Hi,
I am not sure what I am doing wrong, but CYGACC_CALL_IF_FLASH_CFG_OP is not finding the value (returning false). I am trying to read the "bootp_my_ip" value. Every time the card restarts the redboot sees the right values, so it doesn't seem to be an issue of data getting over-written.
Below are the modifications I made to network_support.c in the net/common package:
#include <cyg/hal/hal_if.h>
// For fetching the IP info from RedBoot
#include <cyg/hal/hal_if.h>
#ifndef CONFIG_IP
#define CONFIG_IP 5
#endif
typedef unsigned char ip_addr_t[4];
//
// taken from redboot ... net/net_io.c
//
static bool
flash_get_IP(char *id, ip_addr_t *val)
{
ip_addr_t my_ip[4];
int i;
if (CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET, id, &my_ip, CONFIG_IP))
{
diag_printf("flash_get_IP %s\n", my_ip);
if (my_ip[0] != 0 || my_ip[1] != 0 ||
my_ip[2] != 0 || my_ip[3] != 0) {
// 'id' is set to something so let it override any static IP
for (i=0; i<4; i++)
(*val)[i] = my_ip[i];
}
}
else
{
return false;
}
}
and then in the init_all_networks_interfaces() function I have:
struct in_addr card_ip;
flash_get_IP("bootp_my_ip", card_ip.s_addr);
Any ideas what I might be doing wrong?
Andre
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Reading flash config value from application
2006-06-20 22:26 Andre-John Mas
@ 2006-06-21 2:15 ` Gary Thomas
0 siblings, 0 replies; 6+ messages in thread
From: Gary Thomas @ 2006-06-21 2:15 UTC (permalink / raw)
To: ajmas; +Cc: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]
On Tue, 2006-06-20 at 18:26 -0400, Andre-John Mas wrote:
> Hi,
>
> I am not sure what I am doing wrong, but CYGACC_CALL_IF_FLASH_CFG_OP is not finding the value (returning false). I am trying to read the "bootp_my_ip" value. Every time the card restarts the redboot sees the right values, so it doesn't seem to be an issue of data getting over-written.
>
> Below are the modifications I made to network_support.c in the net/common package:
>
> #include <cyg/hal/hal_if.h>
>
> // For fetching the IP info from RedBoot
> #include <cyg/hal/hal_if.h>
> #ifndef CONFIG_IP
> #define CONFIG_IP 5
> #endif
>
> typedef unsigned char ip_addr_t[4];
>
> //
> // taken from redboot ... net/net_io.c
> //
> static bool
> flash_get_IP(char *id, ip_addr_t *val)
> {
> ip_addr_t my_ip[4];
Do you really want an array of 4 ip_address_t objects?
> int i;
>
> if (CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET, id, &my_ip, CONFIG_IP))
> {
> diag_printf("flash_get_IP %s\n", my_ip);
> if (my_ip[0] != 0 || my_ip[1] != 0 ||
> my_ip[2] != 0 || my_ip[3] != 0) {
> // 'id' is set to something so let it override any static IP
> for (i=0; i<4; i++)
> (*val)[i] = my_ip[i];
> }
> }
> else
> {
> return false;
> }
> }
>
> and then in the init_all_networks_interfaces() function I have:
>
> struct in_addr card_ip;
>
> flash_get_IP("bootp_my_ip", card_ip.s_addr);
>
> Any ideas what I might be doing wrong?
I don't see anything in particular wrong with this code. I tried
the attached program and it worked just fine for me.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
[-- Attachment #2: fconfig_test.c --]
[-- Type: text/x-csrc, Size: 552 bytes --]
#include <stdio.h>
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_if.h>
#include <network.h>
#define CONFIG_IP 5
int
main(int argc, char *argv[])
{
unsigned long addr;
if (CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
"bootp_my_ip",
&addr,
CONFIG_IP)) {
diag_dump_buf(&addr, sizeof(addr));
} else {
printf("Can't get 'bootp_my_ip'\n");
}
printf("fconfig_test done\n");
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-06-21 2:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-16 23:23 [ECOS] Reading flash config value from application André-John Mas
2006-06-17 1:41 ` Gary Thomas
[not found] ` <FAE7AB22-59C4-4C01-8C7E-AC3C86F6E3F1@sympatico.ca>
2006-06-17 21:25 ` Gary Thomas
2006-06-18 3:28 ` André-John Mas
2006-06-20 22:26 Andre-John Mas
2006-06-21 2:15 ` Gary Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).