Skip to content
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

IPAL for CM7 #205

Merged
merged 17 commits into from
Oct 5, 2021
Merged

IPAL for CM7 #205

merged 17 commits into from
Oct 5, 2021

Conversation

marcoaccame
Copy link
Contributor

@marcoaccame marcoaccame commented Oct 4, 2021

This PR adds IP communication to the development board stm32h745disco using the IPAL abstraction layer.

The added code consists of three parts:

  • the IPAL library w/ its API implemented with lwIP and compiled for the STM32H7 MPU
  • the adaptation of the stm32hal to the stm32h745disco board
  • a set of UDP test programs used to verify the UDP stack

Here are fragments of a minimal sample program which successfully respond to a ping.

#include "stm32hal.h"
#include "ipal.h"
#include "ipal_cfg2.h"

Listing. The inclusion files.

int main(void)
{ 
    stm32hal_init(&systickcfg);
    
    itm_puts("hello world");
    
    led_init();
    itm_puts("led initted");

Listing. The initialization of the HW plus some prints.

    uint32_t *data04aligned = nullptr;
    uint32_t size04aligned = 0;
	ipal_base_memory_getsize2(&ipal_cfg2, &size04aligned);
    if(size04aligned > 0)
    {
        data04aligned = new uint32_t[size04aligned/4];
    }    
	ipal_base_initialise2(&ipal_cfg2, data04aligned);

	ipal_sys_start();

Listing. The initialization of IPAL.

    for(;;)
    {    
        ipal_sys_process_communication();
        volatile uint32_t now = HAL_GetTick();		 
		// Every 10 ms invokes the periodic ipal timer_tick function        
        if((now - prevtick) >= tickperiodms)
        {
            prevtick = now;
            ipal_sys_timetick_increment();
            
            // and i toggle the led every 200 ms
            static uint32_t tt = 0;
            if(0 == (++tt%20))
            {
                led_toggle();
            }
        }
    }    

Listing. The running of IPAL.

And in here is a flavor of the configuration variable called ipal_cfg2.

static const ipal_cfg2_eth_t ethcfg2 =
{
    .eth_mac = IPAL_mac48addr(0x1E,0x30,0x6C,0xA2,0x45,0x5E),
    .eth_ip = IPAL_ipv4addr(10, 0, 1, 99),
    .eth_mask = IPAL_ipv4addr(255, 255, 255, 0),
    .eth_isrpriority = 0,
    .filler = {0, 0, 0, 0, 0, 0, 0},
    .hal_eth_init = ipal_hal_eth_stm32h7_init,
    .hal_eth_enable = ipal_hal_eth_stm32h7_enable,
    .hal_eth_disable = ipal_hal_eth_stm32h7_disable,
    .hal_eth_sendframe = ipal_hal_eth_stm32h7_sendframe,
    .get_frame_size = ipal_hal_eth_stm32h7_get_frame_size,
    .get_frame = ipal_hal_eth_stm32h7_get_frame    
};
...
constexpr uint32_t tout = 10;

static const ipal_cfg2_extfn_t extfncfg2 = 
{
    .usr_on_fatal_error = ipal_app_on_fatal_error,
    .signal_rx_frame = ipal_app_usr_on_rx_frame,
    .signal_tx_frame = ipal_app_usr_on_tx_frame,
    .osal_mutex_new = osal_mutex_new,
    .osal_mutex_take = osal_mutex_take,
    .osal_mutex_release = osal_mutex_release,
    .osal_param_tout_forever = 10,
    .dummy = 0 
};

const ipal_cfg2_t ipal_cfg2 = 
{
    .support = (ipal_cfg2_support_t*) &suppcfg2,
    .system = (ipal_cfg2_system_t*) &syscfg2,
    .eth = (ipal_cfg2_eth_t*) &ethcfg2,
    .arp = (ipal_cfg2_arp_t*) &arpcfg2,
    .udp = (ipal_cfg2_udp_t*) &udpcfg2,
    .igmp = (ipal_cfg2_igmp_t*) &igmpcfg2,
    .dhcp = NULL,
    .extfn2 = (ipal_cfg2_extfn_t*) &extfncfg2    
};

Listing. The configuration of IPAL.

For mode details refer to the project in path icub-firmware\emBODY\eBcode\arch-arm\board\stm32h745disco\examples\basicping.

Tests
The tests have shown that the new stack works on the stm32h745disco board. Moreover the new code does not interfere w/ code already running on the robot.

@marcoaccame marcoaccame marked this pull request as draft October 4, 2021 15:34
@marcoaccame marcoaccame marked this pull request as ready for review October 5, 2021 07:30
@marcoaccame marcoaccame merged commit 702a353 into robotology:devel Oct 5, 2021
@marcoaccame marcoaccame deleted the test/udp-h7 branch January 11, 2022 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant