-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
ports/rp2: Change MICROPY_PY_LWIP setting value and netinfo structure. #9862
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
Changes from 1 commit
80c17ef
d93a724
e1094c3
8612af1
693de0e
d11ef62
3e8daad
85bf7ab
7f50ef9
5aa9829
22c4973
3d3e789
0ad7506
c120d11
fae5335
42100f0
22e8c8d
613da47
7eedac7
4038c39
0ed85af
37baba7
0769ab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,15 +368,6 @@ STATIC void wiz_dhcp_conflict(void) { | |
} | ||
|
||
STATIC void wiznet5k_init(void) { | ||
// Configure wiznet provided TCP / socket interface | ||
|
||
reg_dhcp_cbfunc(wiz_dhcp_assign, wiz_dhcp_update, wiz_dhcp_conflict); | ||
|
||
uint8_t sn_size[16] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; // 2k buffer for each socket | ||
ctlwizchip(CW_INIT_WIZCHIP, sn_size); | ||
|
||
ctlnetwork(CN_SET_NETINFO, (void *)&wiznet5k_obj.netinfo); | ||
|
||
// set some sensible default values; they are configurable using ifconfig method | ||
wiz_NetInfo netinfo = { | ||
.mac = {0, 0, 0, 0, 0, 0}, | ||
|
@@ -388,6 +379,17 @@ STATIC void wiznet5k_init(void) { | |
}; | ||
wiznet5k_obj.netinfo = netinfo; | ||
|
||
// Configure wiznet provided TCP / socket interface | ||
|
||
reg_dhcp_cbfunc(wiz_dhcp_assign, wiz_dhcp_update, wiz_dhcp_conflict); | ||
|
||
uint8_t sn_size[16] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; // 2k buffer for each socket | ||
ctlwizchip(CW_INIT_WIZCHIP, sn_size); | ||
|
||
ctlnetwork(CN_SET_NETINFO, (void *)&wiznet5k_obj.netinfo); | ||
|
||
|
||
|
||
// register with network module | ||
mod_network_register_nic(&wiznet5k_obj); | ||
|
||
|
@@ -766,7 +768,13 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size | |
STATIC mp_obj_t wiznet5k_regs(mp_obj_t self_in) { | ||
(void)self_in; | ||
printf("Wiz CREG:"); | ||
#if _WIZCHIP_ == 5500 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than duplicating the for loop 3 times, can you do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than having the |
||
for (int i = 0; i < 0x50; ++i) { | ||
#elif _WIZCHIP_ == 5105 | ||
for (int i = 0; i < 0x90; ++i) { | ||
#else | ||
for (int i = 0; i < 0x60; ++i) { | ||
#endif | ||
if (i % 16 == 0) { | ||
printf("\n %04x:", i); | ||
} | ||
|
@@ -896,11 +904,11 @@ STATIC mp_obj_t wiznet5k_ifconfig(size_t n_args, const mp_obj_t *args) { | |
self->netinfo.dhcp = NETINFO_STATIC; | ||
mp_obj_t *items; | ||
mp_obj_get_array_fixed_n(args[1], 4, &items); | ||
netutils_parse_ipv4_addr(items[0], netinfo.ip, NETUTILS_BIG); | ||
netutils_parse_ipv4_addr(items[1], netinfo.sn, NETUTILS_BIG); | ||
netutils_parse_ipv4_addr(items[2], netinfo.gw, NETUTILS_BIG); | ||
netutils_parse_ipv4_addr(items[3], netinfo.dns, NETUTILS_BIG); | ||
ctlnetwork(CN_SET_NETINFO, &netinfo); | ||
netutils_parse_ipv4_addr(items[0], self->netinfo.ip, NETUTILS_BIG); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this change. I think it makes sense, but it would be good to clarify -- is self->netinfo only for DHCP or is it correct to also put the static address into it? What goes wrong if you don't make this change? |
||
netutils_parse_ipv4_addr(items[1], self->netinfo.sn, NETUTILS_BIG); | ||
netutils_parse_ipv4_addr(items[2], self->netinfo.gw, NETUTILS_BIG); | ||
netutils_parse_ipv4_addr(items[3], self->netinfo.dns, NETUTILS_BIG); | ||
ctlnetwork(CN_SET_NETINFO, &self->netinfo); | ||
return mp_const_none; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,10 @@ if (MICROPY_PY_LWIP) | |
target_compile_definitions(${MICROPY_TARGET} PRIVATE | ||
MICROPY_PY_LWIP=1 | ||
) | ||
else() | ||
target_compile_definitions(${MICROPY_TARGET} PRIVATE | ||
MICROPY_PY_LWIP=0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be necessary. The default will be zero. |
||
) | ||
endif() | ||
|
||
if(MICROPY_PY_BLUETOOTH) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,14 @@ BOARD ?= PICO | |
|
||
BUILD ?= build-$(BOARD) | ||
|
||
LWIP ?= 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it makes sense to put this into This is an unfortunate detail of the way the CMake system works, but I don't think adding each individual option to the Makefile is the right way to solve it. |
||
|
||
MICROPY_PY_WIZNET5K ?= 5105 | ||
|
||
$(VERBOSE)MAKESILENT = -s | ||
|
||
CMAKE_ARGS = -DMICROPY_BOARD=$(BOARD) | ||
CMAKE_ARGS += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) | ||
|
||
ifdef USER_C_MODULES | ||
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES} | ||
|
@@ -26,6 +31,7 @@ ifdef BOARD_VARIANT | |
CMAKE_ARGS += -DBOARD_VARIANT=${BOARD_VARIANT} | ||
endif | ||
|
||
CMAKE_ARGS += -DMICROPY_PY_LWIP=${LWIP} | ||
HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m" | ||
|
||
all: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# cmake file for Wiznet W5100S-EVB-Pico. | ||
set(PICO_BOARD wiznet_w5100s_evb_pico) | ||
set(MICROPY_PY_NETWORK_WIZNET5K W5100S) | ||
set(MICROPY_PY_LWIP 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should stay (unless there's some reason we want to stop using LWIP on these boards?) @andrewleech ? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# cmake file for Wiznet W5500-EVB-Pico. | ||
set(PICO_BOARD wiznet_w5100s_evb_pico) | ||
set(MICROPY_PY_NETWORK_WIZNET5K W5500) | ||
set(MICROPY_PY_LWIP 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense (calling
ctlnetwork
after actually initialising netinfo), but maybe only thectlnetwork
line needs to move?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right,
In conclusion, after initializing netinfo, call the ctlnetwork function and set the network-related register to the initialized value