For half-duplex mediums, you might want to change the EZBL_FLOW_THRESHOLD value, for example, at global/file-scope, add: EZBL_SetSYM(EZBL_FLOW_THRESHOLD, 96);
The default was 18 bytes in EZBL v2.04 and is 32 bytes in EZBL v2.10.
The net effect of making this change will be that the bootloading logic will generate a lot less outbound software flow control messages and better throughput could be achieved. Each message is a 16-bit integer advertising how many bytes of free space are currently available in the software RX FIFO, less any free space previously advertised, but not yet delivered to the RX FIFO (or recognized by software, even though the data may actually be already sitting in the FIFO due to background ISR processing).
For the best performance and a solution that doesn't depend on the bootloader task execution frequency, I recommend implementing a custom, blocking TX_FIFO_OnWrite()
callback function and delete or disable the _U1TXInterrupt()
ISR. In your UART1_TX_FIFO_OnWrite() callback, you would:
1. Wait for all RX activity or potential RX activity to cease
2. Set your TX Enable line
3. Copy reqWriteLen
bytes of data from *writeSrc
4. Purge the existing data from destFIFO by calling EZBL_FIFORead((void*)0, destFIFO, bytesPushed);
5. Poll for hardware transmit completion
6. Clear the TX Enable and revert to RX mode
7. Return reqWriteLen
Implementing step 1 might entail polling until:U1STAHbits.RIDLE && ((UART1_RxFifo.dataCount >= EZBL_bootCtx.bytesRequested) || (NOW_32() - startTime > NOW_ms*2u))
where startTime is set to NOW_32() before the test and continuously during the polling loop whenever (!U1STAHbits.RIDLE). The idea is to timeout after the greater of several character idle times or a couple milliseconds to ensure the medium is idle and the remote host node won't transmit anything else. A fixed couple milliseconds is helpful since things like USB to UART transceivers will operate at the mercy of the USB bus, which typically implements a 1ms polling interval for Full Speed USB devices and adds a relatively fixed round trip communications latency.
In normal operation dataCount should match bytesRequested when the PC node stops transmitting, but the timeout is still necessary since the end of file activities involve advertising buffer free space, even though the host node doesn't have any .bl2 file data left to transmit to the Bootloader.
The _U1TXInterrupt() code can be left in place but disabled by setting the interrupt priority to 0. Statically you could use:EZBL_SetSYM(UART1_TX_ISR_PRIORITY, 0);
At run-time you could write directly to the IPCx registers to control this, or in EZBL v2.10, via the EZBL_FIFOSetIntPri(&UART1_TxFifo, 0); API. Of course, deleting all code that sets the _U1TXIE bit will also work, but finding this code could be error prone since it could theoretically be written to indirectly via calls to EZBL_FIFOIntEnable(), EZBL_FIFOIntEnableSet(), UART1_FIFO_EnableInterrupts(), EZBL_SetIntEn(), EZBL_WrIntEn(), EZBL_InvIntEn(), UART1_TX_FIFO_OnWrite(), etc., even though the current releases of EZBL don't actually call all of these.
post edited by HowardSchlunder - 2018/08/21 15:37:37