Finally I was able to fix it. I will make this answer a small guide with the steps for ezbl projects.
I comment the answer here because it will be usefull for other peoples.
When you change version 4.2 to version 5.4 even when compiler is the same version (1.35) and ezbl is the same version too (2.11) is that you need to take specially care about file of "hardware initializers" folder.
I changed it and i set the values to the same values than previous version, but it didnt work. I exited with code -24 and also with -25.
Another important thing is follow all the ezbl steps right, i will comment about them later.
You need to open the right file inside "hardware initializers folder" for your device, in my case pic24j256gb410_explorer_16.c
First important thing.. FCY speed, here i had the default speed of the samples (16m). If you set it wrong you will see for example, serial ports transmitting to different speed (4x faster than expected), but not in bootloader, in the final app. Bootloader serial speed will work even if you set wrong the FCY speed.
//#define FCY 16000000ul // Changing this automatically changes the PLL settings to run at this target frequency
#define FCY 4000000ul
Another important detail, set serial speed to the right speed.
const long EZBL_COMBaud = 115200;
Remove from file (comment), all those lines that are not useful to your project.
Btw, if you use certain microcontrollers, some of the pins used there for default file example doesnt exists. Be careful.
Finally the most important thing happens here:
EZBL_SET_CONF(_FSEC, BWRP_OFF & BSS_OFF & BSEN_OFF & GWRP_OFF & GSS_OFF & CWRP_OFF & CSS_DIS & AIVTDIS_DISABLE)
EZBL_SET_CONF(_FOSCSEL, FNOSC_FRC & PLLMODE_PLL96DIV2 & IESO_OFF)
EZBL_SET_CONF(_FOSC, POSCMOD_XT & OSCIOFCN_ON & SOSCSEL_ON & PLLSS_PLL_PRI & IOL1WAY_OFF & FCKSM_CSECME)
EZBL_SET_CONF(_FWDT, WDTPS_PS1024 & FWPSA_PR32 & FWDTEN_SWON & WINDIS_OFF & WDTWIN_PS75_0 & WDTCMX_LPRC & WDTCLK_LPRC)
EZBL_SET_CONF(_FPOR, BOREN_ON & LPCFG_ON)
EZBL_SET_CONF(_FICD, ICS_PGx2 & JTAGEN_OFF & BTSWP_ON)
EZBL_SET_CONF(_FDS, DSWDTPS_DSWDTPS0D & DSWDTOSC_LPRC & DSBOREN_ON & DSWDTEN_ON)
EZBL_SET_CONF(_FDEVOPT1, ALTCMPI_DISABLE & TMPRPIN_OFF & TMPRWIPE_OFF & ALTVREF_ALTVREFDIS)
You need to set config bits for your project, again inside this file.
Why do you set them with EZBL_SET_CONF? because those config bytes will be included in the generated .merge.s file, and tell and force linker in the final app to use them.
; Bootloader code block intended for program region 'FSEC'
; 0x02AF80 to 0x02AF84, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FSEC, address(0x02AF80), code, keep
.pword 0x00FFFF, 0xFFFFFF /* 0x02AF80 ...... */
.popsection
; Bootloader code block intended for program region 'FOSCSEL'
; 0x02AF98 to 0x02AF9C, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FOSCSEL, address(0x02AF98), code, keep
.pword 0x0000F8, 0xFFFFFF /* 0x02AF98 ...... */
.popsection
; Bootloader code block intended for program region 'FOSC'
; 0x02AF9C to 0x02AFA0, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FOSC, address(0x02AF9C), code, keep
.pword 0x00001B, 0xFFFFFF /* 0x02AF9C ...... */
.popsection
; Bootloader code block intended for program region 'FWDT'
; 0x02AFA0 to 0x02AFA4, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FWDT, address(0x02AFA0), code, keep
.pword 0x004BDF, 0xFFFFFF /* 0x02AFA0 .K.... */
.popsection
; Bootloader code block intended for program region 'FPOR'
; 0x02AFA4 to 0x02AFA8, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FPOR, address(0x02AFA4), code, keep
.pword 0x000001, 0xFFFFFF /* 0x02AFA4 ...... */
.popsection
; Bootloader code block intended for program region 'FICD'
; 0x02AFA8 to 0x02AFAC, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FICD, address(0x02AFA8), code, keep
.pword 0x000081, 0xFFFFFF /* 0x02AFA8 ...... */
.popsection
; Bootloader code block intended for program region 'FDS'
; 0x02AFAC to 0x02AFB0, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FDS, address(0x02AFAC), code, keep
.pword 0x0080DF, 0xFFFFFF /* 0x02AFAC ...... */
.popsection
; Bootloader code block intended for program region 'FDEVOPT1'
; 0x02AFB0 to 0x02AFB4, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FDEVOPT1, address(0x02AFB0), code, keep
.pword 0x00001E, 0xFFFFFF /* 0x02AFB0 ...... */
.popsection
; Bootloader code block intended for program region 'FBOOT'
; 0x801800 to 0x801804, length 0x000004 (6 bytes; needs 0 pages)
.pushsection EZBL_BTLDR_CONFIG_WORD_FBOOT, address(0x801800), code, keep
.pword 0x000003, 0xFFFFFF /* 0x801800 ...... */
.popsection
If you set it to the bootloader, it will work for bootloader but not for final application, and int will fail in verification process.
The final and one of the harder problems (and in this case, i think that it is a bug) is the first of those config flags lines.
In my previous project i used
EZBL_SET_CONF(_FSEC, BWRP_OFF & BSS_OFF & BSEN_OFF & GWRP_OFF & GSS_OFF & CWRP_OFF & CSS_DIS & AIVTDIS_DISABLE)
but this generated a different value from previouis version for FSEC config register, i dont remember the value, it started with 0x8..., the problem here is that bootloader was looking for a different value, and i got -25 exit code if i'm not wrong.
I enabled debuggin for bootloader uncommenting
#define EZBL_DEBUG // Uncomment to allow debugging messages to be printed to stdout
#define VERBOSE // Uncomment to have verbose printing of all flash write commands and data
It is important that ezbl by default tries the bootloading process without modifying the memory (to see if the imported file is right) and then it flashes it. So in debugging mode you will see the file failing in first step for app memory addresses (bootloader addresses must be right or you are using a wrong bootloader file).
After a lot of tried i change that line to:
EZBL_SET_CONF(_FSEC, 0xFFFF)
to force the config flags for _FSEC to the right value and the value wanted. I dont know why this version gave me a different value than i got in version 4.2.
When you are able to compile the project, it will generate a .merge.s file and a merge.gld file. As you must know, you need to use those file in your final project.
The .merge.s file goes to source files and the .merge.gld goes to linker files.
VERY IMPORTANT. if you change bootloader file you will need to compile again the final app. In my case it included more steps because the update was done though a SD card, so i had to compile the final app and copy it to the SD and this was one of the main erros that i had, i was offering to the bootloader an incompatible version of the bootloader file (Even if the hash is the same, because the hash is generated with the first lines of ezbl_boot.mk) and it will not change when you make changes to your code, but final bootloader file will be different.
BOOTID_VENDOR = "xxxxx"
BOOTID_MODEL = "xxxx"
BOOTID_NAME = "12/11/2020"
BOOTID_OTHER = "GA410-GA406"
When bootloader file is different verification process will fail in the bootloading update process.
All those was the most important problems and things to take care. If i remember more i will edit and add them.
Note: In my original post i though that it was about nvmkey or eraseall, i was fully wrong...
As i said first step when flashing is verify if the file is right, so you will get a lot of errors in flashing process when debug is enabled because it is not flashing the addresses and then read will be always 0xFFFF. After verifying finish, the real process will start. Here is where it cant fail, if it fails, then you probably mixed bootloaders versions, or you have a problem with the config bits (final app will probaby works fine).