Looks like in libgcrypt's scrypt algorithm implementation, N and P values are wrongly set.
From 1.6.3 to 1.8.1 the values are same as wrong (If i am correct):
u64 N = subalgo; /* CPU/memory cost paramter. */ u32 r; /* Block size. */ u32 p = iterations; /* Parallelization parameter. */
Ideally it should have been
u64 N = iterations; /* CPU/memory cost paramter. */ <<<<<<<<<<< u32 r; /* Block size. */ u32 p = subalgo; /* Parallelization parameter. */ <<<<<<<<<<<
Please let me know