Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ray

Pages: [1] 2
1
Hi Mark,
Yes, I definitely have a general lack of HTML skills, but luckily the online live html editors work really well.

1) I was not properly using   IS_CHECKED, IS_SELECTED, NOT_SELECTED, nor IS_DISABLED  correctly, I think I've got that working.
2) I needed to separate the selection variables on the two controls fnIsSelected *ptrBuffer.  using case "$sCS": for the DST checkbox, and repurposed "$sB_" for the list box
3) commented out all unused options to prevent unintended consequences

I believe it is working correctly, I'll test more over the next few days

I didn't see how to "store" the result of the variable sent to fnHandleWeb()  for the drop down box here:
/sntpcfg.htm?C=g&D=CS&IT0=172.22.1.59&r=Save
I took 'g' and stored it in a local unsigned char variable to use in the fnIsSelected()

unsigned char ListChoice = 0;
static unsigned char fnIsSelected(unsigned char *ptrBuffer)
{
    // Format $sAB (length assumed to be 4 bytes, even when both parameters are not used)
    //
    unsigned char ucCheck = NOT_SELECTED;

    switch (*ptrBuffer++) {
    case 'C':               //  Custom codes
      switch (*ptrBuffer) {
        case 'S':           //  DST checkbox
          if((temp_pars->temp_parameters.ucTimeZoneFlags&0x80)>0) return IS_CHECKED;
          else return NOT_SELECTED;
        default:
          return IS_DISABLED;
      }
    case 'B':               //  Custom codes for time zone choice
      if(ListChoice == *ptrBuffer) return IS_SELECTED;
      else  return NOT_SELECTED;
..
..
..


static int fnHandleWeb(unsigned char ucType, CHAR *ptrData, HTTP *http_session)
{
    static unsigned char  NewTimezoneData = 0;
    unsigned char        *ucPtr;

    switch (ucType) {

    case 'C':                        /// RJS   Variable found "C="_
      switch (*++ptrData) {         // preincrement past '='  need to switch a..z..A..H to capture all 34
      case 'a':
        ListChoice = *ptrData;
        NewTimezoneData = 0; // set the timezone to 'a'
        break;


Thank You!   Everything seems to be running smoothly now.

2
Hi Mark,
I'm sure this is me not understanding HTML, about all I know I've learned doing this project, and html5-editor.net for building tables.
From 3admin.htm  I'm using your SNTP TimeZone drop down box and enable checkbox, and IP address box, but that works They properly save the parameters, however, they don't ever refresh the browser controls so after a save, they don't properly show the selections.  The IP address populates correctly:

HTML:

<form action=sntpcfg.htm name=r>
<table border="0"><tr><th>
<table border="1">
<p style=""font-size: 1.5em;""><strong>SNTP Server configuration</strong></p>
<tr><th>
Time Zone<select name=C>
<option value="a"$sCa0>UTC-12:00
<option value="b"$sCb0>UTC-11:00
<option value="c"$sCc0>UTC-10:00 HAST
<option value="d"$sCd0>UTC-9:00 AKST
<option value="e"$sCe0>UTC-8:00 PST
<option value="f"$sCf0>UTC-7:00 MST
<option value="g"$sCg0>UTC-6:00 CST
<option value="h"$sCh0>UTC-5:00 EST
<option value="i"$sCi0>UTC-4:30
<option value="j"$sCj0>UTC-4:00 AST
<option value="k"$sCk0>UTC-3:30 NST
<option value="l"$sCl0>UTC-3:00
<option value="m"$sCm0>UTC-2:00
<option value="n"$sCn0>UTC-1:00
<option value="o"$sCo0>UTC
<option value="p"$sCp0>UTC+1:00
<option value="q"$sCq0>UTC+2:00
<option value="r"$sCr0>UTC+3:00
<option value="s"$sCs0>UTC+3:30
<option value="t"$sCt0>UTC+4:00
<option value="u"$sCu0>UTC+4:30
<option value="v"$sCv0>UTC+5:00
<option value="w"$sCw0>UTC+5:30
<option value="x"$sCx0>UTC+5:45
<option value="y"$sCy0>UTC+6:00
<option value="z"$sCz0>UTC+6:30
<option value="A"$sCA0>UTC+7:00
<option value="B"$sCB0>UTC+8:00
<option value="C"$sCC0>UTC+9:00
<option value="D"$sCD0>UTC+9:30
<option value="E"$sCE0>UTC+10:00
<option value="F"$sCF0>UTC+11:00
<option value="G"$sCG0>UTC+12:00
<option value="H"$sCH0>UTC+13:00
</select><br>
<tr><th>Enable Daylight Saving <input type=checkbox name=D $sCS><br>
SNTP Server IP<input maxLength=15 size=15 name=IT0 value="$vIT"><br>
<input type=submit value="Save" name=r></form>

The URL is http://172.22.50.34/sntpcfg.htm?C=g&D=on&IT0=172.22.1.59&r=Save

Looking at this, every indication it should open option "g" and provide the enable checkbox, but it doesn't.  It correctly saves the parameters and shows the IP address.

I can live with this on a configuration screen, it's just curious that I thought it would update the chosen parameter





3
Hi Mark,
Actually I'm not sure where that comment about EXT_FLASH_FILE_SYSTEM came from.  Yes, that definitely has no place in the loading process.

I've taken a step back and tried to think logically where the problem might be coming from.
Except for disk_loader.c, serial_loader.c usb_application.c and usb_device_loader.c every other driver file for the serial loader is in the main application.

Except for config.h, loader.h and app_hw_kinetis.h
Clearly, config.h and loader.h are project specific, however, app_hw_kenitis.h has no reason to be different from the main application since it is essentially the glue between the drivers and the hardware layout.  So I took the main application app_hw_kinetis.h, added about 4-5 preprocessor directives and a bunch of fnDebugMsg()   and RESET_PEREPHIALS()

No, same problem.
I did find more issues  usb_device_loader.c does not properly call FAT32.   line 351
#if !defined FAT_EMULATION
    #if !defined iMX_MAX_APPLICATION_SIZE || iMX_MAX_APPLICATION_SIZE <= (512 * 1024)
        #define UTFAT12                                                  *****causes all sorts of problems
    #endif

    #if defined UTFAT12
        #define BOOT_SECTOR_LOCATION           1
        #define BACKUP_ROOT_SECTOR             1
        #define BYTES_PER_SECTOR               512
        #define RESERVED_SECTION_COUNT         2
        #define NUMBER_OF_FATS                 1
    #else                                                                // use FAT32 for large disk sizes
        #define BOOT_SECTOR_LOCATION           63                        // 0x3f
        #define BACKUP_ROOT_SECTOR             6
        #define BYTES_PER_SECTOR               512
        #define RESERVED_SECTION_COUNT         32
        #define NUMBER_OF_FATS                 1
    #endif
#endif
this also affects the default size, and why my MSD shows 2 mb size   line 385:
#if defined UTFAT12
    #define DISK_SIZE                      (2 * 1024 * 1024)             // 16Meg (maximum with FAT12)
    #define FAT_CLUSTER_MASK               FAT12_CLUSTER_MASK            // {46}
#else                                                                    // FAT32 used with larger disk sizes
    #define DISK_SIZE                      (8 * 1024 * 1024)             // 8Meg
    #define FAT_CLUSTER_MASK               FAT32_CLUSTER_MASK            // {46}
    #define FAT_SECTOR_COUNT               ((DISK_SIZE + ((4 * 1024 * 1024) - 1)) / (4 * 1024 * 1024))
#endif
This says the size of the MSD is hardcoded?

I'm convinced the USB MSD isn't gluing to the SPI.  I'm going to drop a bunch of hardware debug uart codes to read on a logic analyzer tomorrow. 

Just for clarity:
the proper configuration in config.h is:
  #define SPI_FILE_SYSTEM                                                // we have an external file system via SPI interface  *** definitely need this
  //#define FLASH_FILE_SYSTEM                                         // we have an internal file system in FLASH               *** Actually It seems we don't need this
    #define FLASH_ROUTINES                                              // supply flash routines                                              *** definitely need this
    #define SPI_FLASH_W25Q                                             // internal QSPI flash                                                  *** needed to add this

#if defined (SPI_FILE_SYSTEM) || defined (FLASH_FILE_SYSTEM) || defined (NVRAM) || defined INTERNAL_USER_FILES
    //#define ACTIVE_FILE_SYSTEM                   // Removed RJS 8/31/2023    // enable uFileSystem  ***this seems to mess with the MSD in the main application, doesn't work with this defined
#endif

also, I'm pretty sure I've got this correct  (config.h) starting 1693ish

    #else
   // #define SDCARD_SUPPORT                                       // SD-card interface (only choose one of these options at a time)   ** meaning either SDCARD  OR SPI_FAT_FLASH
    #endif
    #define SPI_FLASH_FAT                                              // SPI flash                                                                                        *** definitely need this
        #define SIMPLE_FLASH                                           // don't perform block management and wear-leveling                    *** definitely need this
      //  #define FLASH_FAT_MANAGEMENT_ADDRESS     (SIZE_OF_FLASH)                                                                                  *** not used 
    #if (defined ST_MB997A_DISCOVERY && defined DEV11)
        #define RENAME_SDCARD_FILE_AFTER_UPDATE                        // once new firmware has been copied from the SD card it will be automatically renamed
    #else
      //#define RENAME_SDCARD_FILE_AFTER_UPDATE                        // once new firmware has been copied from the SD card it will be automatically renamed
      #define DELETE_SDCARD_FILE_AFTER_UPDATE                          // once new firmware has been copied from the SD card it will be automatically deleted from the card
    #endif
    #if (defined SERIAL_INTERFACE && !defined REMOVE_SREC_LOADING)
      //  #define UTFAT_DISABLE_DEBUG_OUT    //9-1-2023 RJS removed           // disable general mass-storage output so that the SREC loader is not disturbed
    #endif
    #if (defined DELETE_SDCARD_FILE_AFTER_UPDATE || defined USE_USB_MSD)
        #define UTFAT_WRITE
    #endif


Thanks, 

Ray


4
Hi Mark,
I have a tiny bit of improvement, or maybe better clues.
I downloaded the latest  remotes/origin/V2.0.0  latest commit 8/24/2023
Recall I am using the KinetisK60, parameters and swap blocks are last 4k of the 512k, no internal filesystem, the SPI flash MSD appears to work completely on the application so no hardware problem.
 
I've detailed the exact changes I made from the original to get to a point of hardware USB enumeration, incorrect enumeration, and the debug UART 3 spits out:

Debug output when powering the board and reading debug uart 3:
_DISPLAY_SD_CARD_NOT_PRESENT()   1 second delay  _DISPLAY_SD_CARD_NOT_PRESENT()    1 second delay _DISPLAY_SD_CARD_NOT_PRESENT() fnDebugMsg("No Application!!\r\n");

Clearly the hardware USB USB_MSD_DEVICE_LOADER  components are being pulled in correctly to enumerate the USB MSD, but the SPI_FLASH is not being setup correct, so it is failing this part.

config.h changes
comment line 108          #define TEENSY_3_1
uncomment line 127      #define TWR_K60N512         //  MK60DN512VLQ10
Uncomment line 1258    #define SPI_FILE_SYSTEM     // we have an external file system via SPI interface
comment line  1259       #define FLASH_FILE_SYSTEM   // we have an internal file system in FLASH

***  question regarding line 1270   #define ACTIVE_FILE_SYSTEM  This line must be commented out in my application or my FAT32 gets corrupted continuously.  Is this a special case directive?   
When my application has this defined my flash ships FAT32 is continuously corrupted

***  possible issue   **
Between 1275 and 1364  there are different configurations defines for the spi flash, however NONE are set
ADDing 2 lines after this block ***#if (defined FLASH_FILE_SYSTEM && defined SPI_FILE_SYSTEM)***  that runs from   1275 to 1364
1365  #define SPI_FLASH_W25Q                                                  // use Winbond W25Q SPI flash rather than ATMEL
1355 #define FILE_GRANULARITY (4 * SPI_FLASH_BLOCK_LENGTH)                    // defined in app_hw_kinetis.h

uncomment 1715        #define SPI_FLASH_FAT   
comment 1775            #define UTFAT16  // not needed

since I am loading from onboard IC's  I should be able to comment this out so the debugger will send debug messages?
#define UTFAT_DISABLE_DEBUG_OUT   // disable general mass-storage output so that the SREC loader is not disturbed

Loader.h  ** not much here to change  starting location is 0x9080 in the linker as I have shown in previous comments
change line 203 from 23 to 36    #define UTASKER_APP_START     (36 * 1024)   
change line 217  from 64 to 476  #define UTASKER_APP_END   (unsigned char *)(UTASKER_APP_START + (476 * 1024)) // use entire chip



app_hw_kinetis.h
Clocking Changes for my PCB:
Change line 375 from      #define EXTERNAL_CLOCK       50000000    to   #define CRYSTAL_FREQUENCY           24000000
Change line 376 to  CRYSTAL_FREQUENCY
Change  378  to 12
delete a space at 480 and insert a new line at 376  #define OSC_LOW_GAIN_MODE     
change line 804 to be PACKAGE_LQFP
Insert into blank line at 676    #define MASK_5N22D    // RJS  9/21/2022

GPIO changes:
edit lines 1809 - 1813 to PORTE_BIT26
edit lines 1821-1825 to PORTE_BIT25
edit lines 1834 watchdog init to use port E
edit 1873 and 1874  to define them to zero #define INIT_WATCHDOG_DISABLE() 0    WATCHDOG_DISABLE() 0 
Edit line 1884 to use port E

edit line 1890 to define to 1 always forcing serial loader #define FORCE_BOOT()         1         Always enter serial loader to check
edit line 1900 to define to 0 always leave loader mode     #define RETAIN_LOADER_MODE() 0
  Never, always proceed


Copy lines 4808  to 4839  outside of the preprocessor define area
begin with line 4841 

#else
#define CS0_LINE                        SPI_PUSHR_PCS0           // CS0 line used when SPI FLASH is enabled
#define CS1_LINE                        SPI_PUSHR_PCS1           // CS1 line used when extended SPI FLASH is enabled
#define CS2_LINE                        SPI_PUSHR_PCS2           // CS2 line used when extended SPI FLASH is enabled
#if defined SPI_FLASH_DEVICE_COUNT && (SPI_FLASH_DEVICE_COUNT >= 4)
#define CS3_LINE                    SPI_PUSHR_PCS3           // CS3 line used when extended SPI FLASH is enabled
#endif

#define SPI_CS0_PORT                    ~(SPI0_PUSHR)            // for simulator
#define SPI_CS1_PORT                    ~(SPI0_PUSHR)            // for simulator
#define SPI_CS2_PORT                    ~(SPI0_PUSHR)            // for simulator
#define SPI_CS3_PORT                    ~(SPI0_PUSHR)            // for simulator
#define SPI_TX_BYTE                     SPI0_PUSHR               // for simulator
#define SPI_RX_BYTE                     SPI0_POPR                // for simulator
#define POWER_UP_SPI_FLASH_INTERFACE()  POWER_UP_ATOMIC(6, SPI0)
#define CONFIGURE_SPI_FLASH_INTERFACE() _CONFIG_PERIPHERAL(D, 0, (PD_0_SPI0_PCS0 | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                                _CONFIG_PERIPHERAL(D, 1, (PD_1_SPI0_SCK | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                                _CONFIG_PERIPHERAL(D, 2, (PD_2_SPI0_SOUT | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                                _CONFIG_PERIPHERAL(D, 3, (PD_3_SPI0_SIN));\
                                                SPI0_MCR = (SPI_MCR_MSTR | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF | SPI_MCR_PCSIS_CS0 | SPI_MCR_PCSIS_CS1 | SPI_MCR_PCSIS_CS2 | SPI_MCR_PCSIS_CS3 | SPI_MCR_PCSIS_CS4 | SPI_MCR_PCSIS_CS5);\
                                                SPI0_CTAR0 = (SPI_CTAR_DBR | SPI_CTAR_FMSZ_8 | SPI_CTAR_PDT_7 | SPI_CTAR_BR_2 | SPI_CTAR_CPHA | SPI_CTAR_CPOL); // for 50MHz bus, 25MHz speed and 140ns min de-select time

#define POWER_DOWN_SPI_FLASH_INTERFACE() POWER_DOWN(6, SIM_SCGC6_SPI0) // power down SPI interface if no SPI Flash detected

#define FLUSH_SPI_FIFO_AND_FLAGS()      SPI0_MCR |= SPI_MCR_CLR_RXF; SPI0_SR = (SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF);

#define WRITE_SPI_CMD0(byte)            SPI0_PUSHR = (byte | SPI_PUSHR_CONT | ulChipSelectLine | SPI_PUSHR_CTAS_CTAR0) // write a single byte to the output FIFO - assert CS line
#define WRITE_SPI_CMD0_LAST(byte)       SPI0_PUSHR = (byte | SPI_PUSHR_EOQ  | ulChipSelectLine | SPI_PUSHR_CTAS_CTAR0) // write final byte to output FIFO - this will negate the CS line when complete
#define READ_SPI_FLASH_DATA()           (unsigned char)SPI0_POPR
#define WAIT_SPI_RECEPTION_END()        while ((SPI0_SR & SPI_SR_RFDF) == 0) {}
#define CLEAR_RECEPTION_FLAG()          SPI0_SR |= SPI_SR_RFDF
#define SET_SPI_FLASH_MODE()                                     // this can be used to change SPI settings on-the-fly when the SPI is shared with SPI Flash and other devices
#define REMOVE_SPI_FLASH_MODE()                                  // this can be used to change SPI settings on-the-fly when the SPI is shared with SPI Flash and other devices

line 4874 is the new
#endif
 
 
 
With these changes  I get 2 failures in KinetisSim.c (uFILE_START)  and WinSim.c (FILE_SYSTEM_SIZE)  NOT FOUND
 
I add  into app_hw_kinetis.h  4875 and 4876
#define FILE_SYSTEM_SIZE   (128*1024)
#define uFILE_START   (512 * 1024)






5
This one really has be stumped. 
Yes, the main application when installed by itself, will enumerate the 16Mb SPI_FLASH_W25Q128.
That is the drive with a root directory for an HTTP simple interface so the web folder is on the spi flash chip and works perfectly as a standalone.

The main application when using a serial loader installs at 0x9080  The serial loader hex file confirms everything is in the correct location. 
It feels like the Serial loader is failing somewhere when accessing the spi flash device.   The serial loader enumerates a USB MSD in windows however it is only an empty 1.32 Mb  I'm hoping this is  a clue because I don't believe the chip actually is being accessed.  I use that old windows SDK program usbview.exe to read the setup info. 

The serial loader enumerates MSD but then just hangs, not jumping to the app.   
When I install only the serial loader it continually reboots and enumerates that same false value, seems like a wtd reboot.

also, in kinetis_FLASH.h when EXT_FLASH_FILE_SYSTEM  is defined,  the switch statement has a case  _STORAGE_PARALLEL_FLASH and is calling undefined functions fnWriteParallelFlash(), and fnGetExtFlashAdd().  (causes compile error)

Maybe that is a clue? I just comment out those functions since its about parallel flash not SPI flash




6
Let me add the simulator UART debug output:
 uTasker Serial Loader V1.5

===========================

[0x00009080/0x0007ffff]

me = mass erase

bc = blank check

dc = delete code

ld = start load

go = start application

> SD-Card presentAndFormatted       *** added AndFormatted to verify what I was seeing on simulator *  this is a formatted W25QXXX.ini with no code on it

SD JumpToApp(disk_loader-328)        *** I added this just before fnJumpToApplication(1);                              // {3} unconditional jump to application code

No Application (Serial_loader-4413)

Thanks
Ray

7
Hi Mark

On a main application, the SPI_FILE_SYSTEM  based on SPI_FLASH_W25Q128 devices (16MB)  seems to work perfectly as a USB MSD. 
(I needed to commented out   // #define ACTIVE_FILE_SYSTEM    which appeared to mess with my FAT32 format)
Reading and writing files and dragging folders to the DISK seems to be fully operational. 

I've had the serial loader with the SDCARD working, but flash chips are a whole lot better solution for me.
It's time for me to tackle the problem with the serial loader.  First, just treating it as a USB MSD doesn't seem to work.  with the  #defines set like this, it seems to lockup. 

loader.h
#define UTASKER_APP_START     (36 * 1024)
#define UTASKER_APP_END           (unsigned char *)(UTASKER_APP_START + (476 * 1024))
#define _UTASKER_APP_START_   (UTASKER_APP_START + (ROOT_FILE_ENTRIES * 32))

config.h of serial loader
    #define USB_INTERFACE                                                // enable USB driver interface
#define USB_MSD_DEVICE_LOADER                                 // USB-MSD device mode (the board appears as a hard-drive to the host)
   
#define USB_DEVICE_SUPPORT             
#define USB_MSD_TIMEOUT       
#define SPI_FLASH_FAT                                                // SPI flash
#define SIMPLE_FLASH                                             // don't perform block management and wear-leveling
#define FLASH_FAT_MANAGEMENT_ADDRESS     (SIZE_OF_FLASH)
#define DELETE_SDCARD_FILE_AFTER_UPDATE   

#define UTFAT_WRITE
#define UTFAT_LFN_READ                                               // enable long file name read support
#define STR_EQUIV_ON                                                 // ensure that this routine is available
#define UTFAT_LFN_WRITE
#define UTFAT_LFN_WRITE_PATCH
#define RANDOM_NUMBER_GENERATOR
#define UTFAT_RETURN_FILE_CREATION_TIME   

Nothing works, it locks up, but  creates a USB_MSD

UPLOAD_DISK(F:)  1.31 MB free of 1.32MB 

This is incorrect because the flash chip is fully formatted with a folder f:\web and it's lone file when I run the application code.

I think the problem is it's not correctly configured for what it is. 

I have it configured with #define USB_MSD_DEVICE_LOADER
however I don't think this is the proper way for it to be implemented for my use-case.

For the initial programming of a new board, the serial loader should fail with this:  #define _DISPLAY_SD_CARD_NOT_PRESENT() fnDebugMsg("SD-Card not present\r\n")
Jump to the main application, and then the main application has a initialization with formats the new device...and all is well.

I'm confused as to how exactly I configure SPI_FLASH as a MSD for the serial loader?  Is it an "SD Card" or USB Device? 
It seems to to walk the line and be a little bit of both?
I noticed I can't just use USB_MSD and SDCARD_SUPPORT

FYI - when I have a properly formatted W25QXXX.ini  the UART3.txt indicates
> SD-Card presentAndFormatted
No Application

I'd like it to act like a SDCARD and the USB doesn't need to do anything until it jumps to the main application.
Debug is fine with just the UART


Oh, some other details are the linker edits, although I feel I have them correctly setup.

and my K_512_128_BM.ld uses:
MEMORY
{
    FLASH (rx) : ORIGIN = 0x00009080, LENGTH = 0x00080000-0x9080         /* 512k Flash - boot loader */
    SRAM (wx)  : ORIGIN = 0x1fff01f0, LENGTH = 0x00020000-0x1f0          /* 128k RAM with vector size 0x1f0 (488 bytes - maximum for all processors) */
}

SECTIONS
{
  __SRAM_segment_start__   = 0x1fff01f0;
  __SRAM_segment_end__     = 0x2000ffff;
  __Vector_segment_start__ = 0x00009080;                                 /* application start address */
  __Vector_segment_end__   = 0x0000908f;
  __FLASH_segment_start__  = 0x00009090;
  __FLASH_segment_end__    = 0x0007ffff;
Thanks
Ray

8
#if defined defined USER_INFO_MASK   
Actually should be
#if defined USER_INFO_MASK

The copy/paste demon wins again  :)

I'll update and test

Thanks
Ray

9
Hi Mark,
I stared at that 'M' and while it didn't set off the right alarms for me, it did seem odd.  Yes, that fixed my SNMP_TASK problem and now I am able to use the fnRetry(socket,n) to pull from the queue.

Ah, now that worked, but...  Yes a little more.
This makes sense now:
unsigned char ucSNMP_manager = ((socket >> USER_INFO_SHIFT) & USER_INFO_MASK); // extract the snmp manager information

socket is a 5 bit (max 31 sockets, no socket 0)
Needed to extract
        #define USER_INFO_SHIFT      5
        #define USER_INFO_MASK       0x03                                // 4 users supported
        #define SOCKET_NUMBER_MASK   0x1f                                // single network and interface with up to 4 user functions (USOCKET can be single byte width)
      
      
This is the root cause of my fnSendUDP failure too.   I believe you meant to do something with this preprocessor directive _UDP_SOCKET_MASK(SocketHandle); 
in tcpip.h   (487)    #define _UDP_SOCKET_MASK(uSocket)         (uSocket)
however, it doesn't do anything and allows the top 3 bits to shine through.

I actually solved this by doing this instead:
SocketHandle = (SOCKET_NUMBER_MASK & SocketHandle);

extern signed short fnSendUDP(USOCKET SocketHandle......)
UDP_TAB *ptrUDP = tUDP;
  SocketHandle = (SOCKET_NUMBER_MASK & SocketHandle);
  if ((SOCKET_NUMBER_MASK & SocketHandle)> UDP_SOCKETS){ //(_UDP_SOCKET_MASK(SocketHandle) > UDP_SOCKETS) {                  // {7}
      return INVALID_SOCKET_HANDLE;
  }
  if ((uMemcmp(dest_IP, cucNullMACIP, IPV4_LENGTH)) == 0) {
      return(INVALID_DEST_IP);
  }
      
   By the time we are in fnSendUDP()  no other info seems necessary,
   
   if somehow I haven't thought this completely through, I think you might want me to update the #define _UDP_SOCKET_MASK(uSocket)  (uSocket&SOCKET_NUMBER_MASK)
   
   At this point my traps on all 3 managers are being received without me resorting to forcing any ARP requests outside of the normal ARP algorithm.

10
Hi Mark,
Well, I'm drilling down and feel I'm close to the root problem, I must be missing something important.

The ARP appeared to be contributing to the problem because it changed so frequently in my noisy environment. 
Locking down the ARP to only required entries from requests seemed to solve the problem however, my system failed in the middle of the night.  Modbus worked, SNMP GET worked, UDP broadcast worked.  Everything but traps. 

With another solid day of debugging with the simulator, I think I've reached a conclusion: 
TASK_SNMP is not in the taskTable and unable to process the trap queue. extern void fnSNMP(TTASKTABLE *ptrTaskTable)
This is how the trap queue draws down, and resends when the message from ARP arrives.  This task is never called.

I added //uTaskerStateChange(TASK_SNMP, UTASKER_ACTIVATE); to my period timer and it falied to find a TASK_SNMP entry
I tried to follow extern TASK_LIMIT uTaskerStart()  these are the tasks it loaded

wdog
ARP
Eth
TCP
usb
O-MOD
app
maintenance
MassSt
DHCP
dNS
period
IGMP
NetInd
keeper
1
2
3
4
5 mine
6 mine
7 mine
8 mine
9 mine
lowPower
NULL

I'm not sure why SNMP doesn't get processed into the task array?

11
Hi Mark,
Yes, I believe ARP is not the root cause, rather, it is possible the ARP process is just a little overwhelmed in my noisy network envornment.
The ARP request for 172.22.0.1 is for the gateway, probably for NTP - I've disabled this for now.


I mistakenly changed one of the ARP_IGNORE_FOREIGN_ENTRIES  in static void fnSendARP_response(ARP_INPUT *ptrArpInput)
On line 682, if we received our own ARP request, it wasn't being added, I have fixed this.
What I meant to comment out was your suggestion in fnHandleARP_response()
That is now commented out with the preprocessor, however it didn't fix the problem of extra ARP entires.

Additionally, there is an instance of fnAddARP() located in ip.c  line 688
This was adding all the misc ARP's it received, I have diabled with the preprocessor, now my ARP table has 3 and only 3 entries (+ broadcast)

This didn't resovle my trap problem. The symptom was trap manager 1 worked but 2 or 3 didn't.   
As always your amazing debugger to the rescue and discovered in static int fnSendTrap() function, line 1099 fnSendUDP()  has extra information OR'd into the SocketHandle and would fail the first check.   

Commenting this allows traps beyond manager 1 to send /* | ptrSNMP_manager_details[iManagerRef].snmp_manager_details | ((iManagerRef & USER_INFO_MASK) << USER_INFO_SHIFT)*/
I have no idea what those values are for, but commenting them out allows my 3 managers to receive traps.

if (fnSendUDP((USOCKET)(SNMPSocketNr /* | ptrSNMP_manager_details[iManagerRef].snmp_manager_details | ((iManagerRef & USER_INFO_MASK) << USER_INFO_SHIFT)*/)  ,(unsigned char*)ptrSNMP_manager_details[iManagerRef].snmp_manager_ip_address, SNMP_MANAGER_PORT, (unsigned char*)&UDP_Message.tUDP_Header, (unsigned short)iNewLength, OWN_TASK) == NO_ARP_ENTRY)

which failes the first check of fnSendUDP(USOCKET SocketHandle, unsigned char *dest_IP, unsigned short usRemotePort, unsigned char *ptrBuf, unsigned short usDataLen, UTASK_TASK OwnerTask)

    if (_UDP_SOCKET_MASK(SocketHandle) > UDP_SOCKETS) {                  // {7}
        return INVALID_SOCKET_HANDLE;
    }
   
Cautiously, all is well...I'm running a 5 day blast on coldstart traps to make sure we don't bog down.

Thank You
Ray

12
I should add I appear to be getting the same result in the simulator.  This is where my debug effort currently is.   

13
Hi Mark,
I really thought I had the SNMP traps working, but somehow It is again failing.  To troubleshoot, I temporarily added 7 MIB spots for the ARP table as a debug because CLI isn't available.  On the included wireshark filtered capture  the first entry is ARP to the SNMP manager, and my 2 test traps flow freely   .  then appx 75 seconds in it appears to be an ARP refresh?
then traps are locked out   then 5 minutes later a gateway ARP refresh? then 5 minutes later traps begin for a short time, then ARP blocking again.  Eventually the system locks up with this - but my Modbus polling is good and SNMP GET communication is unaffected?   Just traps.

Since this is very odd behavior, I'm guessing that my method for sending traps is the problem. 
However, my ARP table is full of unwanted entries despite having ARP_IGNORE_FOREIGN_ENTRIES defined.



so I think I've got 2 questions:
1)  Is the ARP_IGNORE_FOREIGN_ENTRIES  supposed to ignore all random ARP requests on the network?  It doesn't appear to do this based on the ipaddresses in the ARP table

2)  Do SNMP traps need to be implemented in a specific way so that they get an ARP notification?  do they need to be called within the snmp void fnSNMP(TTASKTABLE *ptrTaskTable)??


Thanks
Ray




in my MIB handler, the extern unsigned char fnInitialiseSNMP(void)  ( called in Application.c - in my fnPIT_timerTask  every 5 seconds)

        if (ulCount_5000ms) --ulCount_5000ms;
        else
        {
          ulCount_5000ms = 500;
          if (SnmpStarted == 0)
          {
           if( fnInitialiseSNMP() == 1) SnmpStarted = 1;
          }
          else
          {
            if (SendColdStartTrap == 0)
            {
                fnSendSNMPTrap(SNMP_COLDSTART, 0, 1);//ALL_SNMP_MANAGERS);
                SendColdStartTrap = 1; 
            }
            else// cold start has been sent
            {
              fnSendSNMPTrap(SNMP_COLDSTART, 0, 1);//  test with just the easy to send trap
            }
          }


14
Hi Mark
I absolutely did not check that  :)   As I was reading thru the pdf manual it was mentioning the default phy address was 00001  4 weak pull downs, one weak pull up.  Yes, my PHY_ADDRESS was defined to 0.   setting to 1 and now I can read phy registers!!   

I've been waiting months to check that one off my list!

Thanks for the help!!

ray

15
Thanks Mark

It's strange how intellisense is spotty in my VS2022 for this file - but if I double click the kinetis_ENET.h in kinetis.c  the kinetis_ENET.h see's preprocessor info highlighted again.

Unfortunately, I'm still not getting anything but 0xffff when I query the phy registers on the command line. I know my MDIO lines are placed properly this time with a 1.5k p/u I think I need to very carefully attach some skywires to my previous MQX based design to see if MDIO is actually working on MQX code.

 

Pages: [1] 2