Pin shift in ATMEGA 4808

I made a PCB with an AtMega4808.
I’m using MegaCoreX & JTAG2UPDI (without bootloader) to program it.
I started my test with “blinking” the different I/O that I use to make sure everything is working correctly, and found a strange “offset” in the pin’s numbers:

With some of the microcontroller legs if I blink output N the corresponding pin turns on/off.
But for some I need to blink output N+2 to get pin N to turn on/off
I test the output with oscilloscope.

I use this simple updated blink code:

#define p1 7

void setup() {
  pinMode(p1, OUTPUT);
}

void loop() {
  digitalWrite(p1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a second
  digitalWrite(p1, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(300);                      // wait for a second
}

When p1 = 7 the microcontroller pin 5 turns on/off
When p1 = 25 the microcontroller pin 25 turns on/off

Why is this so?
How should I correctly address the microcontroller pins?

Assuming you're using the pinout=32pin_standard, physical pin 5 is PA7 and physical pin 25 is PF5.

In variants/32pin-standard/pins_arduino.h you'll find the following mapping:

// Arduino pin macros
#define PIN_PA0 0
#define PIN_PA1 1
#define PIN_PA2 2
#define PIN_PA3 3
#define PIN_PA4 4
#define PIN_PA5 5
#define PIN_PA6 6
#define PIN_PA7 7
#define PIN_PC0 8
#define PIN_PC1 9
#define PIN_PC2 10
#define PIN_PC3 11
#define PIN_PD0 12
#define PIN_PD1 13
#define PIN_PD2 14
#define PIN_PD3 15
#define PIN_PD4 16
#define PIN_PD5 17
#define PIN_PD6 18
#define PIN_PD7 19
#define PIN_PF0 20
#define PIN_PF1 21
#define PIN_PF2 22
#define PIN_PF3 23
#define PIN_PF4 24
#define PIN_PF5 25
#define PIN_PF6 26

You can plainly see the the PIN_PA7 is #defined as 7, PIN_PF5 is defined as 25.

So when you're blinking the pin defined as 7 in the core, that maps to I/O PA7, which is on physical pin 5. Similarly, when you're blinking the pin defined as 25 in the core, tha maps to I/O PF5, which is on physical pin 25.

In short, the pin numbers used by the core have nothing at all to do with the physical pin numbers on the IC.

Thanks,
That was exactly what I was looking for!
I did tried to use (as written in KiCad)
#define p1 PA4
But did not know I had to use PIN_PA4